Can someone explain what this function does?
Hi guys,
I need to re-write this function in scheme but I'm confused on what this function even does, can someone explain it to me?
Thanks
Code:
int aFunction(int n) {
int c;
for (int c = 1; c != 0; ) {
if (n > 100) {
n = n - 10; c--; }
else {
n = n + 11; c++; }
}
return n;
}
Re: Can someone explain what this function does?
It looks some some simple numerical trickery. Rewriting it in a different language probably shouldn't require in-depth understanding of the mathematics.
EDIT: Heh. I think it'll probably always return the same value if the initial n < 100.
EDIT2: I'll give you this much: The function could be simplified to the form
max(n-m,k). I'll let you figure out what m and k are.