Write a program to Find Factors of Number in Python
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# Python Program to find the factors of a number # define a function def print_factors(x): # This function takes a number and prints the factors print("The factors of",x,"are:") for i in range(1, x + 1): if x % i == 0: print(i) #to take input from the user num = int(input("Enter a number: ")) print_factors(num) |