0

Prime number program giving "wrong answer"

# Python program to check if the input number is prime or not num = 99 # take input from the user # num = int(input("Enter a number: ")) if num > 1: for i in range (2,num): if (num%1) == 0: print(num, "is not a prime number") print (i, "times", num//i, "is", num) break else: print (num, "is a prime number") else: print (num, "is not a prime number") ********************** When I run this I get ********************* 99 is not a prime number 2 times 49 is 99 ******************************************** This is not quite right, is this due to a float issue or not describing the number as an interger? Thanks for the help in advance!

7th Jul 2019, 6:26 AM
Rafael Granados
Rafael Granados - avatar
2 Respostas
+ 3
It should be: if (num%i) == 0: 99 is dividable by 33.
7th Jul 2019, 6:35 AM
Paul
Paul - avatar
- 1
Propably just a typing mistake
7th Jul 2019, 7:55 AM
Seb TheS
Seb TheS - avatar