In this program, we will find all factors of a number.
Steps to solve the program
- Take a number as input through the user.
- Divide the number by every number before it using for loop with the range function.
- Print only those numbers that can divide the given number completely.
num = int(input("Enter a number: "))
for i in range(1,num+1):
if num % i == 0:
print(i,end=" ")
Output :
Enter a number: 25
1 5 25