maynul67

Find all prime Factors of a given number

Jul 13th, 2021
950
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def is_prime(num):
  2.     for i in range(2,num):
  3.         if (num % i) == 0:
  4.             return False
  5.     return True
  6.  
  7. def all_prime(n):
  8.     list = []
  9.     for a in range(2,n):
  10.         if is_prime(a) == True:
  11.             list.append(a)
  12.     return list
  13.    
  14. n= int(input("enter number: "))
  15. b = all_prime(n)
  16.  
  17. def prime_factors(n):
  18.     factors = []
  19.     for c in b:
  20.         if n % c == 0:
  21.             factors.append(c)
  22.     return factors
  23.  
  24. e = prime_factors(n)
  25. print(e)
RAW Paste Data