As for the number of creases, we tried to find a set rule for that before realizing its would be much easier to explain using recursion. The following code fragment shows the way the number of creases (returned) compares to the number of folds (x)
public int crease ( int x ) {
if ( x == 1)
return 1;
else
return 2 * crease (x - 1) + 1;
}
I'm fairly certain this code is correct, but I haven't worked with Java for a while and there may be a mistake or two. Anyway, this exercise was interesting, and while I didn't manage to completely explain the solution I found it to be good practice in analytical reasoning.
LOL nice title haha. I honestly enjoyed this lesson. Was very interesting! Its just so cool how we can turn mathematical problems into programs!
ReplyDelete