How can i calculate the the (nth fibonacci)th fibonacci number mod M with (n, M <= 10^9)

Revision en2, by hoainiem, 2021-10-28 16:09:31

I have a problem about fibonacci numbers: ==================

let f[i] be the ith fibonacci number

f[i] = 1 (1 <= i <= 2)

f[i] = f[i-1] + f[i-2] (i > 2)

how can i calculate f[f[n]] mod M (n, M <= 10^9). anyone can help me?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English hoainiem 2021-10-28 16:09:31 62
en1 English hoainiem 2021-10-28 16:07:19 315 Initial revision (published)