Advertisement
kevinbocky

divisors.py

May 7th, 2020
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #Create a program that asks the user for a number and then prints out a list of all the divisors of that number.
  2. #(If you don’t know what a divisor is, it is a number that divides evenly into another number.
  3. #For example, 13 is a divisor of 26 because 26 / 13 has no remainder.)
  4.  
  5.  
  6. num = input("Enter a number, i will find all the divisors \n")
  7. if num.isdigit():
  8. num = int(num)
  9. div = [i for i in range(1,num + 1 ) if num % i == 0]
  10. print(div)
  11. else:
  12. print("Wrong entry \n ")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement