Learn about the Program to Find Factors of a Number in Python in the below code example. Also, refer to the comments in the code snippet to get a detailed view about what’s actually happening.
Program to Find Factors of a Number in Python
The factor of the number “N” is a number that entirely divides the number “N.” For example, the digits 1, 2, 3, and 6 are all complete divisions of the number 6, hence they are referred to as the factor of 6. When we divide a number that is completely divisible, the outcome is zero.
# Python program to find factors of a number # user input num = int(input('Enter number: ')) # find factors of number print('The factors of', num, 'are:') for i in range(1, num+1): if(num % i) == 0: print(i, end=' ')
Enter number: 6
The factors of 6 are: 1 2 3 6
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Code : Fibonacci Series in Python using Recursion