Menu Close

Prime Factor

Python Program to Compute Prime Factors of an Integer

numb=int(input('Enter the number: '))
ls=[]
for i in range(2,numb): # This gives common factors
  if numb%i==0:
    ls.append(i)
    
for i in range(len(ls)):
  s=0
  for j in range(2,ls[i]):  # From the common factor, we find the prime numbers
    if ls[i]%j==0:
      s+=1
  if(s==0):
    print(ls[i])

Input:
        Enter the number: 3999
Output:
        3
        31
        43


Input:
       Enter the number: 6000
Output:
       2
       3
       5


Sample Output Pic ?

Executed using terminal linux

More Codes to Fcuk