def linear_recurrence(n, (a, b)=(2, 0), (u0, u1)=(1, 1)):
 i = 0
 (u, v) = (u0, u1)
 while (i < n):
  w = ((a * v) + (b * u))
  (u, v) = (v, w)
  i += 1
 return w

def linear_recurrence ( n , ( a , b ) = ( 2 , 0 ) , ( u0 , u1 ) = ( 1 , 1 ) ) : i = 0 ( u , v ) = ( u0 , u1 ) while ( i < n ) : w = ( ( a * v ) + ( b * u ) ) ( u , v ) = ( v , w ) i += 1 return w
return nth term of the sequence defined by the linear recurrence u = a*u + b*u(n) .