Python Program to Find Factors of Number live practice
In this tutorial, you will learn how to write Python Program to Find Factors of Number.
# Python Program to find the factors of a number
x = 100
print("The factors of",x,"are:")
for i in range(1, x + 1):
if x % i == 0:
print(i)
Output:
The factors of 100 are: 1 2 4 5 10 20 25 50 100
By Using User Input:
# Python Program to find the factors of a number x = int(input("enter value to find factors")) print("The factors of",x,"are:") for i in range(1, x + 1): if x % i == 0: print(i)
Output :
enter value to find factors 150 The factors of 150 are: 1 2 3 5 6 10 15 25 30 50 75 150