Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from fractions import *
- def realloop(n):
- L=[[Fraction(1,1)]]
- while n>1:
- x=[]
- for i in L[-1]:
- x+=[Fraction(i.numerator+i.denominator,i.denominator),Fraction(i.numerator,i.numerator+i.denominator)]
- L.append(x)
- n=n-1
- t=[]
- for i in L:
- t+=i
- return t
- def calkin(n):
- L=[(1,1)]
- yield L[0]
- while n>1:
- for i in L:
- x=[]
- yield (i[0]+i[1],i[1])
- yield (i[0]+i[1],i[1])
- L=[(x[0],x[1]+x[0]) for x in L]+[(x[0]+x[1],x[1]) for x in L]
- n=n-1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement