This will tell you if the number you enter is divisible by 1-15 this took me some time so i would really appreciate people to upvote me. Enjoy!
x = int(input("Enter in a number")) for i in range(15) if x % i == 0: print("Your number " + str(x) + " is divisible by " + str(i)) else: print("Your number " + str(x) + " is NOT divisible by " + str(i))
1307674368000 in the number input :P
also, you should validate user input. If the user entered a non int (not a number) or a float (decimal) it returns an error.
Here is how its done:
while True: try: x = int(input("Enter ANY number and this will tell you if it is divisible by 1 -15 REMEMBER TO UPVOTE: ")) break except: print("Please enter a number!")
Hi! I looked at your code, I think that you could have used a loop to test more numbers like this(i don't know python, so I will do pseudocode
loop until you reach the number If number mod index equals 0 print divisible by index else print not divisible by index
It's pretty cool! I would suggest using a for loop instead of nearly the same statement pasted a bunch of times. You could also skip most of the composite numbers from 1-15, other than 2, 3, and 5. You don't have to do an if statement for 1.