Write a python program: Print of all divisors of the number

 


Write a program in python, to print divisor of a given number

Steps:

  1. Ask User to enter a Number
  2. Use for loop over 1 to 100 to check divisor
  3. use if loop to find the correct number

Enter a number between 1 to 100 : Print divisor of number :96
1 is divisor of number  96
2 is divisor of number  96
3 is divisor of number  96
4 is divisor of number  96
6 is divisor of number  96
8 is divisor of number  96
12 is divisor of number  96
16 is divisor of number  96
24 is divisor of number  96
32 is divisor of number  96
48 is divisor of number  96
96 is divisor of number  96
Second Method
Enter a number between 1 to 100 : Print divisor of number:96
The number has following divisors:[1, 2, 3, 4, 6, 8, 12,16, 24, 32, 48, 96]

0 Comments