|
-
September 5th, 2008, 10:23 AM
#1
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;
}
-
September 5th, 2008, 10:30 AM
#2
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.
Last edited by Lindley; September 5th, 2008 at 10:49 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|