python - Fibonacci Sequence Mod 1000000007 -



python - Fibonacci Sequence Mod 1000000007 -

everyone knows fibonacci sequence goes

f[0]=1, f[1]=1, f[2]=2, f[3]=3, f[4]=5, f[5]=8,

with f[n] = f[n-1]+f[n-2]

now, how compute number in fibonacci sequence when taken modulo 1000000007 = 10^9+7?

needs run efficiently possible, , in python language :)

for illustration f[10**15] should take less sec or so

i know matrix exponentiation works, how right matrix exponentiation reflect modulo? (another example, see http://www.nayuki.io/page/fast-fibonacci-algorithms)

python

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -