int min = 0, max = 20000, cur = (min+max)/2;
if between min and cur, color it red, if it's between cur and max, color it green, if it's equal to cur color it blue.
if the object is red;
max = cur;
cur = (max+min) / 2;
if it's green;
min = cur;
cur = (max+min) / 2;
if it's blue; log it.
0 / 10000 / 20000 - red
0 / 5000 / 10000 - red
0 / 2500 / 5000 - red
0 / 1250 / 2500 - green
1250 / 1875 / 2500 - red
1250 / 1562 / 1875 - red
1250 / 1406 / 1562 - red
1250 / 1328 / 1406 - green
1328 / 1367 / 1406 - red
1328 / 1347 / 1367 - red
1328 / 1337 / 1347 - blue
Heyyy, it's 1337 and we only needed 11 steps.
You can find everything here;
https://www.mpgh.net/forum/showthread.php?t=84959
steps(x) = ceil(log(x) / log (2))