Python Program:

- To print all the factors of a number

Example:

User Input: 15

Output:
Factors of 15 : 1 3 5 15

num=int(input("Enter your number : "))

print("Factors of ",num)
for i in range(1, int(num/2)+1) :
  if num%i==0 :
    print(i, end=" ")
print(num)

Output:

  Enter your number : 18
  Factors of 18 : 1 2 3 6 9 18
Program
number

You should know first :

Factor of N : All numbers which perfectly divides N


Main Logic :

for i in range(1, int(num/2)+1) :
  if num % i==0 :  # Checking for the factor
    print(i, end=" ")
print(num)

We are running the loop num/2 Since, any number can have only factors under its half, except itself

Concept

Coming Soon !

Quick
Tutorial

Quote

Make bold choices and make mistakes. It’s all those things that add up to the person you become.