14 lines
614 B
Python
14 lines
614 B
Python
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]
|