Python Program to Find Factors of a Number

In this example, we will write a user-defined function that prints the factors of a number. Factors of a number are those number that divides the number without any remainder. To better understand this example, make sure you have knowledge of the following tutorials:-

Python Program to Find Factors of a Number

The output of the above program is:-

Enter a number: 430
The factors of 430 are:
1
2
5
10
43
86
215
430
Program Explanation:-
In this program, user input is taken using input() function and passed to a function print_factors() which takes one argument, num as input. The for loop is used to iterate from 1 to num+1 which checks for the condition where the number is exactly divided or not. If the number is exactly divided, then, the output is printed.
SHARE Python Program to Find Factors of a Number

You may also like...

Leave a Reply

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

Share