Python example to find Factors of a Number

num = int(input('Enter number: '))
# find factor of number
print('The factors of', num, 'are:')
for i in range(1, num+1):
    if(num % i) == 0:
        print(i, end=' ')

OUTPUT:

Enter number: 20
The factors of 20 are:
1 2 4 5 10 20
Enter number: 100
The factors of 100 are:
1 2 4 5 10 20 25 50 100
Enter number: 225
The factors of 225 are:
1 3 5 9 15 25 45 75 225

Leave a Comment