In this Python program, we will learn how to find the factors of a given number and display it.
Here is the code of the program to find the factors of a given number and display it.
# Python Program to Find the Factors of a Given Number
# This function calculates the factor of the argument passed
def Display_factors(x):
print("\nThe factors of",x,"are:")
for i in range(1, x + 1):
if x % i == 0:
print(i)
num = int(input("Enter the Number: "))
Display_factors(num)
Enter the Number: 6
The factors of 6 are:
1
2
3
6
Enter the Number: 8
The factors of 8 are:
1
2
4
8
Comments