[Tutor] help with prime number program
Norman Silverstone
norman at littletank.org
Mon Oct 31 14:41:03 CET 2005
On Mon, 2005-10-31 at 06:12 -0500, Kent Johnson wrote:
> Norman Silverstone wrote:
> > I am a beginner so, I hope what I give, makes sense. In it's simplest
> > form what is wrong with :-
> >
> > n = input("Enter a number")
> > if n % 2 != 0 and n % 3 != 0:
> > print n, " Is a prime number"
> >
> This only gives the correct answer if n < 25. You can't test against a fixed list of divisors, there will always be a non-prime whose divisors are not in your list.
Thank you for your comment which, if I understand you correctly, implies
that prime numbers greater than 25 will not be recognised. Surely, that
cannot be correct. However, if it is correct, could you please
demonstrate what you mean for my education.
Norman
More information about the Tutor
mailing list