1 2 3 4 5 |
|
Given the above function what is the value of
fun(10000, 9950)
?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Claim: f ( p , q ) = q + 2 1 p ( p + 1 ) . Proof by recursion on p :
If p = 0 then f ( 0 , q ) = q is correct.
Assume that the equation is true for some value p . Then f ( p + 1 , q ) = f ( p , p + 1 + q ) = ( p + 1 + q ) + 2 1 p ( p + 1 ) = q + ( p + 1 ) + 2 1 p ( p + 1 ) = q + 2 1 ( p + 2 ) ( p + 1 ) , showing that the equation is then also true for p + 1 .
Therefore the equation holds for all integer values p ≥ 0 .
The answer, then, is 9 9 5 0 + 2 1 ⋅ 1 0 0 0 0 ⋅ 1 0 0 0 1 = 5 0 0 1 4 9 5 0 .