Factor

A factor is an integer that can be divided evenly into another number or in other words factors of a number are numbers that multiply to form a product.

Logic

To print all the factors of a particular number we have to iterate through all the smaller numbers up to the given number. If the user given number is completely divisible by any number then it is a factor of that number.

Program

# Taking input from user
num = int(input("Enter any number : "))

print("\nAll factors of", num, "are : ")

for i in range(1, num + 1):

    # Completely divisible or not.
    if(num % i == 0):
        print(i, end = " ")

Output

Enter any number : 50
All factors of 50 are :
1 2 5 10 25 50