Python Program to Find Factors of a Number

python programs

Problem: Write a program in python to find and print all the factors of a number.


Input:  15
Output: [1, 3, 5]

To find factors of any number in Python, we need to follow the following steps:

  1. Input a number (num)
  2. Loop from 1 to num and check if num is divisible by them or not.
  3. If yes then that number is the factor of num.

Recommended: Python For Loop

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

#empty list for storing factors
factors = []

for i in range(1,num):
    if num%i == 0:


Enter a number: 15
[1, 3, 5]

Leave a Reply

Your email address will not be published. Required fields are marked *