A function f is defined recursively by f(1)=f(2)=1 and f(n)=f(n−1)−f(n−2)+nfor all integers n≥3. What is f(2018)?
(A)
2016
(B)
2017
(C)
2018
(D)
2019
Solution — click to reveal
For all integers n≥7, note that f(n)=f(n−1)−f(n−2)+n=[f(n−2)−f(n−3)+n−1]−f(n−2)+n=−f(n−3)+2n−1=−[f(n−4)−f(n−5)+n−3]+2n−1=−f(n−4)+f(n−5)+n+2=−[f(n−5)−f(n−6)+n−4]+f(n−5)+n+2=f(n−6)+6. It follows that f(2018)=f(2012)+6=f(2006)+12=f(2000)+18⋮=f(2)+2016=2017.