Find all factors of a number using Python.

In this program, we will find all factors of a number.

Steps to solve the program
  1. Take a number as input through the user.
  2. Divide the number by every number before it using for loop with the range function.
  3. 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 
				
			

find the power of a number

calculate the factorial of a number

Leave a Comment