- 追加された行はこの色です。
- 削除された行はこの色です。
[[問題文>練習問題#k489212c]]
# -*- coding: utf-8 -*-
N = 10000
# 素因数分解
def f(n):
res = []
d = 2
while d * d <= n:
while n % d == 0:
res.append(d)
n /= d
d += 1
if n > 1:
res.append(n)
return res
for i in xrange(1, N+1):
a = f(i)
y = i
while 1:
fin = 1
for e in a:
while a.count(e) >= 2:
y /= (e ** 2)
a.remove(e)
a.remove(e)
fin = 0
if fin:
break
x = (i / y) ** .5
res = '√%d '
x = int((i / y) ** .5)
res = '√{0} -> '
if y == 1:
print (res + '-> %d') % (i, x)
print (res + '{1}').format(i, x)
elif x == 1:
print (res + '-> √%d') % (i, y)
print (res + '√{1}').format(i, y)
else:
print (res + '-> %d√%d') % (i, x, y)
print (res + '{1}√{2}').format(i, x, y)