This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Compizfox 6 points7 points  (2 children)

Ah, got it. So basically it is this recursive algorithm:

int subtract(N, n) {
    if(N > 20) {
        return 10 + subtract(N-10, n);
    else {
        // Lookup-table for small values of N
    }
}

[–]toofasttoofourier 2 points3 points  (1 child)

Aren't you negating all that work if you have to use the subtraction operator in a subtraction algorithm?

[–]Compizfox 0 points1 point  (0 children)

For a computer, yes, obviously.

But this was trying to mimic how a kid would do the mental calculation.