Define a function f mapping positive integers to positive integers by f(1)=1, and f(n)=f(n-1)+n if f(n-1)<=n
and f(n)=f(n-1)-n if f(n-1)>n
For n≥2,
i) Find the smallest integer n such that f(n) = 1,000,000
ii) Find the smallest integer n such that f(n) = 2,000,000
Yes - this recursive fn is interesting. Here is an image:
It goes up and down on each n, so, as plotted, fills a block.