Spaces:
Sleeping
Sleeping
File size: 887 Bytes
e3af2b1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
BASE = 2
with open('cyclic_result.txt', 'w') as f:
def to_binary(a, b):
temp = a
chk = [a]
ret = ''
while True:
temp *= BASE
if temp > b:
temp -= b
ret += '1'
elif temp == b:
ret += '1'
return (0, '.' + ret)
else:
ret += '0'
chk.append(temp)
if (len(chk) - len(set(chk))) != 0:
for i in range(len(chk) - 1):
if chk[i] == chk[-1]:
ret = ret[:i] + 'r' + ret[i:]
break
return len(ret[ret.index('r'):]) - 1, '.' + ret
nu = int(input('분자: '))
end = int(input('끝: '))
for i in range(nu + 1, end):
if to_binary(nu, i)[0] == i - 1:
f.write(str(i) + ', ') |