Re: [Tutor] help with prime number program

2005-10-31 Thread Danny Yoo
On Mon, 31 Oct 2005, 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

Re: [Tutor] help with prime number program

2005-10-31 Thread Alan Gauld
> n = input("Enter a number") > if n % 2 != 0 and n % 3 != 0: > print n, " Is a prime number" > > Comments please. According to this 25 is a prime number Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tut

Re: [Tutor] help with prime number program

2005-10-31 Thread Norman Silverstone
> > 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. > > More precisely, it will g

Re: [Tutor] help with prime number program

2005-10-31 Thread Kent Johnson
Norman Silverstone wrote: > 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

Re: [Tutor] help with prime number program

2005-10-31 Thread Glen Wheeler
From: "Norman Silverstone" <[EMAIL PROTECTED]> > 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 an

Re: [Tutor] help with prime number program

2005-10-31 Thread Norman Silverstone
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" > >

Re: [Tutor] help with prime number program

2005-10-31 Thread Kent Johnson
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

Re: [Tutor] help with prime number program

2005-10-31 Thread Norman Silverstone
> I am trying to write a program that will figure out if a number is prime > or not. Currently this is the code that I have: > > import math > > def main(): > > number=input("Please enter a positive whole number greater than 2: ") > for value in range(2, number-math.sqrt): > if

Re: [Tutor] help with prime number program

2005-10-30 Thread Adam
    > 1.  What is 'exit'? instead of exit I can use break so that the loop will stop executing> 2.  What is 'number - math.sqrt'?for math.sqrt I could use math.sqrt(n) so that it would take the sqrt of nwhich is entered in by the userHowever for the output I am still receivingenter a numbe

Re: [Tutor] help with prime number program

2005-10-30 Thread andrade1
> > >> I am trying to write a program that will figure out if a number is prime >> or not. Currently this is the code that I have: > > [code cut] > > Hi Andrade1, > > As in your other previous homework programs, you seem to have some trouble > with control flow. Have you considered talking with yo

Re: [Tutor] help with prime number program

2005-10-30 Thread Danny Yoo
> I am trying to write a program that will figure out if a number is prime > or not. Currently this is the code that I have: [code cut] Hi Andrade1, As in your other previous homework programs, you seem to have some trouble with control flow. Have you considered talking with your professor or

[Tutor] help with prime number program

2005-10-30 Thread andrade1
Hello I am trying to write a program that will figure out if a number is prime or not. Currently this is the code that I have: import math def main(): number=input("Please enter a positive whole number greater than 2: ") for value in range(2, number-math.sqrt): if number % value