Python program to Find all Prime Factors of given number

Posted by
# Prime Factors of given number

# Number :- 24 
# Factors :- 1 2 3 4 6 12 24
# Prime Factors :- 2 3 ( 1 is not prime number)

num=int(input("enter number :- "))

prime_factors=[]
for i in range(1,num+1):
    if i==1:
        continue
    if num%i==0:
        flag=0
        for j in range(2,i):
            if i%j==0:
                flag=1
                break
        if flag==0:
            prime_factors.append(i)
print(prime_factors)           

Leave a Reply

Your email address will not be published. Required fields are marked *