I’ve written this very simple prime number check:
prime = int(input())
if prime % prime == 0 and prime % 2 != 0 and prime % 3 != 0 or prime == 2 or prime == 3:
print("true")
else:
print("false")
… which seems to work somehow, but i’m not certain if its the correct way, can someone please confirm?
It isn’t. To give one counterexample, it thinks that
25is a prime number. To make matters worse, there are infinitely many such counterexamples.Wikipedia is worth of a read for various (correct) methods of doing this.