I have this problem where I have to "audit" a percent of my transtactions.
If percent is 100 I have to audit them all, if is 0 I have to skip them all and if 50% I have to review the half etc.
The problem ( or the opportunity ) is that I have to perform the check at runtime.
What I tried was:
audit = 100/percent
So if percent is 50
audit = 100 / 50 ( which is 2 )
So I have to audit 1 and skip 1 audit 1 and skip 1 ..
If is 30
audit = 100 / 30 ( 3.3 )
I audit 2 and skip the third.
Question
I'm having problems with numbers beyond 50% ( like 75% ) because it gives me 1.333, ...
When would be the correct algorithm to know how many to audit as they go?... I also have problems with 0 ( due to division by 0 :P ) but I have fixed that already, and with 100 etc.
Any suggestion is greatly appreciated.