Input number and print factors using for loop in Python
for Loop - Question 9
In this question, we will see how to input a number and print its factors in Python programming using for loop. To know more about for loop click on the for loop lesson.
Q9) Write a program in Python to input a number and print its factors using for loop.
Program
n=int(input('Enter a number '))
print('Factors are')
for i in range(1,n+1):
if n%i==0:
print(i)
Output
Enter a number 12 Factors are 1 2 3 4 6 12