I wrote a code to search for the closest value to the given one, they told me that it was bad, but why they didn’t answer, actually, maybe someone will say.
static int nearest(int n, int...args) { int nearest = 0; for(int i = 0; i < 1; i++) { int r1 = 0; int r2 = n; for(int j = 0; j < args.length; j ++) { r1 = n - args[j]; if(r1 < 0) { r1 *= -1; } if((r1) == 0) { nearest = args[j]; break; } else { if(r2 > r1) { r2 = r1; nearest = args[j]; } } } } return nearest; }
nearest( 1, 100, 200 )will return 0 - zRrr