import itertools def primefactors(x): factorlist=[] loop=2 while loop<=x: if x%loop==0: x/=loop factorlist.append(loop) else: loop+=1 return factorlist x=input() alist=primefactors(x) for L in range(1, len(alist)+1): for subset in set(itertools.combinations(alist,L)): print(subset)
Console:
36
(2,) (3,) (2, 3) (3, 3) (2, 2) (2, 2, 3) (2, 3, 3) (2, 2, 3, 3)
No comments :
Post a Comment