Posted: Wed Jan 25, 2012 8:49 pm Post subject: RE:Outputting Prime Numbers
Like what I am thinking is to set up all the variables and use a IF condition. If you divide the number by itself, it should give you 1. Could you PLEASE help me. Like with a bit of code?
Thanks
ihsh
Posted: Wed Jan 25, 2012 10:18 pm Post subject: Re: Outputting Prime Numbers
Just in case that you didn't know, the operator mod can give you the remainder when you divide two numbers. For example, (9 mod 5) equals to 4, and (4 mod 2) equals to 0.
Using this operator and a for loop, you can check if a number has any divisor other than 1 and itself, and thereby determine whether it is a prime or not.
Tony
Posted: Wed Jan 25, 2012 10:25 pm Post subject: Re: RE:Outputting Prime Numbers
varman @ Wed Jan 25, 2012 8:49 pm wrote:
If you divide the number by itself, it should give you 1.
Is there any whole number where this is not the case?