def continued_fraction_iterator(x):
 from sympy.functions import floor
 while True:
  i = floor(x)
  (yield i)
  x -= i
  if (not x):
   break
  x = (1 / x)

def continued_fraction_iterator ( x ) : from sympy . functions import floor while True : i = floor ( x ) ( yield i ) x -= i if ( not x ) : break x = ( 1 / x )
return continued fraction expansion of x as iterator .