I have this problem when I have to โcheckโ the percentage of my transactions.
If the percentage is 100, I have to check them, if 0, I must skip all of them, and if 50%, I should look at half, etc.
The problem (or possibility) is that I have to run a check at runtime.
What I tried was:
audit = 100/percent
So, if the percentage is 50
audit = 100 / 50 ( which is 2 )
So, I need to audit 1 and skip 1 audit 1 and skip 1 ..
If 30
audit = 100/30 (3.3)
I check 2 and skip the third.
Question
I have problems with numbers above 50% (e.g. 75%) because it gives me 1.333, ...
When is the correct algorithm to find out how many of them need to be checked when they go? ... I also have problems with 0 (due to dividing by 0: P), but I fixed it already with 100, etc. d.
Any suggestion is much appreciated.
java python language-agnostic c # algorithm
Sony
source share