|
Follow both algorithms using N as the input number:
Algorithm A: N -> N + 1 -> 2(N + 1) = 2N + 2
Algorithm B: N -> 2N -> 2N + 2
Each algorithm produces the same output, as long as you're willing to trust that the distributive property is always true! If you don't trust or remember the distributive property, remember that 2(N + 1) is the same as (N + 1) + (N + 1).
<< back to Problem A1
|