How to find prime factors of a number in python?
Finding the prime factors of a number is a basic program in python which can be done in many ways. We’ll see here how to find prime factors in python using loops.
Number = int(input(" Please Enter any Number: ")) for i in range(2, Number + 1): if(Number % i == 0): isprime = 1 for j in range(2, (i //2 + 1)): if(i % j == 0): isprime = 0 break if (isprime == 1): print(i)
Input- 245 output- 5 7
This is how we can find prime factors of any number.
Please login to comment
View all comments