Today we are going to share a **Python program to print prime factors**. If you are a python beginner and want to start learning the python programming, then keep your close attention in this tutorial as I am going to share a Python program to print prime factors with the output.

To increase your Python knowledge, practice all Python programs, here is a **collection of 100+ Python problems with solutions.**

Copy the below python program and execute it with the help of **python compiler**.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import math # Print all prime factors of given number n def primeFactors(n): while n % 2 == 0: print 2, n = n / 2 for i in range(3,int(math.sqrt(n))+1,2): # while i divides n , print i ad divide n while n % i== 0: print i, n = n / i # Condition if n is a prime # number greater than 2 if n > 2: print n n = 315 primeFactors(n) |

3 3 5 7

If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.

- Important python programs for CBSE Class 11
- Python File Methods
- Python program to add digits of a number
- Python program for subset sum problem
- Generating strong password using Python
- Download Google Images using Python Script
- Python examples on simple mathematical problems
- Program for adding two binary numbers
- Python Program to Solve n-Queen Problem with Recursion
- Python Program to Solve the Celebrity Problem

We use cookies to ensure that we give you the best experience and use cookies in order to personalize the advertising that you see on our website. Read more about our Privacy Policy.Got it!