How to find prime factors of a number in python?
![](https://pythonpoint.net/wp-content/uploads/2020/12/Green-and-Purple-Dynamic-Frames-Action-_-Adventure-YouTube-Channel-Art-1-1024x576.jpg)
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.
e.g.,
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
![](https://pythonpoint.net/wp-content/uploads/2020/12/Screenshot-1048-1024x591.png)
This is how we can find prime factors of any number.
Subscribe
Login
Please login to comment
0 Discussion