David W. answered 09/26/15
Tutor
4.7
(90)
Experienced Prof
If f(0) =1, f(x) =x+f(x-1) for x>0 calculate f(100)?
f(0)=1
f(1)=1 + f(0) = 1 + 1 = 2
f(2)=2 + f(1) = 2 + 2 = 4
f(3)=3 + f(2) = 3 + 4 = 7
f(4)=4 + f(3) = 4 + 7 = 11
f(5)=5 + f(4) = 5 + 11 = 16
...
f(100) = 100 + f(99) = 100 + 4951 = 5051
Wait !! How did I know that f(99) was 4951 ?? Good question !
Each f(x) for x>1 is x plus [the sum of the numbers from 1 to (x-1)] + 1
Remember, f(0)=1
So, for example, the f(4)=11 because it is 4 + [sum of the numbers from 1 to 3] + 1
= 4 + 6 + 1
= 11
Note: Gauss' formula for the sum of the numbers from 1 to N, which is N(N+1)/2, appears at all levels of math and computer science and ... PLZ memorize it.
(p.s., Even the best minds might not notice that f(0)=1, so if you didn't notice it, you're typical).
David W.
I'm finding that my fingers don't always follow what my mind tells them to do (besides being independent, they're getting fat).
Here are 2 of my favorite web items:
A computer does exactly what you tell it to, not what you meant: https://www.youtube.com/watch?v=wPOgvzVOQig
Egoless Programming: https://en.wikipedia.org/wiki/Egoless_programming
Report
09/26/15
Mark M.
09/26/15