Python 2, (削除) 220 (削除ここまで) (削除) 202 (削除ここまで) (削除) 195 (削除ここまで) 183 bytes
g=lambda a,b:a and g(b%a,a)or b;n,d=input();m=c=()
while n+d>2:
t=n*d;f=p=2
while t>p:
if t%p:p+=1;f*=p
else:t/=p
if n%p:c+=p,;n*=f
else:m+=p,;d*=f
t=g(n,d);n/=t;d/=t
print m,c
Try it online! Edit: Saved (削除) 18 (削除ここまで) 25 bytes thanks to @Mr.Xcoder. Saved 12 bytes thanks to @JonathanFrech.
Neil
- 184.4k
- 12
- 76
- 290