Prime factorization of a big number
问题 I'm trying to create a program for prime factorization of a number and this is the code I came up with. def primeFactors(n): l=[] ss=0 for i in range(2,n,1): #checking for prime t=0 for j in range(2,i): if(i==2): continue if(i%j==0): t=t+1 if(t>0): continue else: if(n==0): break else: print(i) if(n%i==0): n=n//i ss=ss+1 i=i-1 if(n%i!=0 and ss>0): l.append(i) l.append(ss) ss=0 else: continue q="" for i in range(0,len(l),2): q=q+"("+str(l[i])+"**"+str(l[i+1])+")" return q The working of the