Python Program to Find Factors of Number

In this post, we will see how to find factors of a number in Python.

Simple program to find factors of number in Python

num=450 #If you want to take input from user, uncomment below line #num=int(input("Enter a number")) for i in range(1,num+1): if(num%i==0): print(i)

Output:

1
2
3
5
6
9
10
15
18
25
30
45
50
75
90
150
225
450

That’s very simple program.

  • Iterate over 1 to range(1,num+1)
  • If current number perfectly divide num, then it is a factor and print it

Thats’all about finding factors of a number in python.

Leave a Reply

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