Advertisement
jkonefal

Untitled

Jan 26th, 2021
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. czyn=[]
  2. n=int(input())
  3. pierw=[0]*(n+2)
  4.  
  5. #for i in range(0,2*n):
  6.     #print(i)
  7.     #pierw.append(int(0))
  8. #print("xd")
  9. for i in range (2,n+2):
  10.     #print(i)
  11.     if pierw[i]==0:
  12.         k=int(1)
  13.         while i*k<=n:
  14.             if pierw[i*k]!=0:
  15.                 pierw[i*k]=min(int(pierw[i*k]),int(i))
  16.             else:
  17.                 pierw[i*k]=int(i)
  18.             k+=1
  19.                
  20.  
  21. while n>1:
  22.    
  23.     print(n,pierw[n])
  24.     czyn.append(pierw[n])
  25.     n//=pierw[n]
  26.     if pierw[n]==0:
  27.         break
  28.  
  29. for i in czyn:
  30.     print(i,end='')
  31.     print(";",end='')
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement