Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,14 @@
|
|||
def r2cf(n1,n2):
|
||||
while n2:
|
||||
n1, (t1, n2) = n2, divmod(n1, n2)
|
||||
yield t1
|
||||
|
||||
print(list(r2cf(1,2))) # => [0, 2]
|
||||
print(list(r2cf(3,1))) # => [3]
|
||||
print(list(r2cf(23,8))) # => [2, 1, 7]
|
||||
print(list(r2cf(13,11))) # => [1, 5, 2]
|
||||
print(list(r2cf(22,7))) # => [3, 7]
|
||||
print(list(r2cf(14142,10000))) # => [1, 2, 2, 2, 2, 2, 1, 1, 29]
|
||||
print(list(r2cf(141421,100000))) # => [1, 2, 2, 2, 2, 2, 2, 3, 1, 1, 3, 1, 7, 2]
|
||||
print(list(r2cf(1414214,1000000))) # => [1, 2, 2, 2, 2, 2, 2, 2, 3, 6, 1, 2, 1, 12]
|
||||
print(list(r2cf(14142136,10000000))) # => [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 6, 1, 2, 4, 1, 1, 2]
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
def real2cf(x):
|
||||
while True:
|
||||
t1, f = divmod(x, 1)
|
||||
yield int(t1)
|
||||
if not f:
|
||||
break
|
||||
x = 1/f
|
||||
|
||||
from fractions import Fraction
|
||||
from itertools import islice
|
||||
|
||||
print(list(real2cf(Fraction(13, 11)))) # => [1, 5, 2]
|
||||
print(list(islice(real2cf(2 ** 0.5), 20))) # => [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
|
||||
Loading…
Add table
Add a link
Reference in a new issue