I want to find out the time complexity of this function by using induction f(n) = 0, if n = 0
f(n) = f(n − 1) + 2n − 1, if n ≥ 1 Im using a method call repeated substitution so then i found a close form for f(n)
f(n)= f(n − 1) + 2n − 1 =f(n-2)+4n-4 =f(n-3)+6n-8 .... =f(n-i)+2^in-d
and then by taking i=n i came out with f(n)=f(0)+2^(n+1)-d and can conclude that is has a time complexity of O(2^n) since f(0) and d are all constants.
however i found the answer should be O(n^2) and where did i do wrong