fork download
  1. def fib_rec ( a, b, p, q, num ):
  2. if ( num == 0 ):
  3. return b
  4. if ( num % 2 == 0 ):
  5. return fib_rec(a, b, p*p+q*q, 2*p*q+q*q, num/2)
  6. return fib_rec(b*q+a*q+a*p, b*p+a*q, p, q, num-1)
  7.  
  8. def power_fib ( N,M ):
  9. # write your code here
  10. numo = N**M
  11. return fib_rec(1, 0, 0, 1, numo)%10000103
  12.  
  13. power_fib ( 3,2 )
Success #stdin #stdout 0.02s 6352KB
stdin
1
2
10
42
11
stdout
Standard output is empty