Help with error

code: https://ide.codingblocks.com/s/455137

I want answer given with 0 based indexing without changing n manually like in this code : -

hello @raghav007

i didnt get ur doubt. what issue u r facing?

series: 0 1 1 2 3 5
for example when I give the input 5 for nth term of fibonnaci series output is 3 but I want the answer to be 5.

then u can simply pass n+1 in place of n . whats the issue?

some test cases are failing , please check the 2nd code I shared above it looks the same as mine but gives the desired output

ok wait i m checking.

@raghav007

can u pls share ur matrix tranformation diagram .

how u are going from one state (n) to (n+1) using f1?

@raghav007
u r using this transformation rigt ?

     [0,1]  f(n)      | f(n+1) 
    [1,1]  f(n+1)    | f(n+2)

yes but I think after writing my code i changed it to for some reason

Blockquote
[1,1]
[1,0]

but it still gave the same answer

changing the order will also change other implementation aspects .

like here -> vector<vector> A = power(n-1, T);
upto what power we need to raise will depen on order.

for(int i = 0; i < k; i++){
res = (res + A[0][i]*f1[i]);
}
this will also change ,depending on what row we want…

this way which I did originally

is this the right code for this transformation matrix

not sure about complete code but with

this tranformation matrix

this is right

I think this code is correct the way it is and for it to work differently I will need to change the relationships and write it differently

@raghav007

handle n=0 seprately and rest is correct.

what changes did you make

just started series from 1 onwards.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.