I need to add all the prime numbers below an arbitrary number.

Printable View

- 06-30-2010, 07:04 PMcidNeed help with a program!
I need to add all the prime numbers below an arbitrary number.

- 06-30-2010, 07:13 PMFubarableQuote:

Do you see what I am doing wrong?

- 06-30-2010, 07:23 PMcid
sorry fubarable we have an understanding now

- 06-30-2010, 07:59 PMJosAH
- 06-30-2010, 10:19 PMNormQuote:

I can't use the % option

What is your algorithm for determining if a number is prime? Not the definition, a list of steps to determine it. - 06-30-2010, 11:07 PMcid
yes, it is a requirement. the way i will find out if a number has a remainder is to multiply by two times the divisor and subtract that from the number.

- 06-30-2010, 11:35 PMNorm
So how is the project doing then?

- 06-30-2010, 11:50 PMcid
horribly. man

- 06-30-2010, 11:53 PMNorm
Try debugging your code by printing out each number it tests and show whether that number is prime or not.

- 07-01-2010, 01:06 AMcid
tried debugging

- 07-01-2010, 01:48 AMNorm
Do the following:

Try debugging your code by printing out each number it tests and show whether that number is prime or not.

Where is the answer to this question?

What is your algorithm for determining if a number is prime? - 07-01-2010, 02:10 AMcid
in order to find out if the number is prime using integers i am subtracting the quotient*divisor from the dividend. if the result is >0 in every instance i am trying to make the program understand that the number is prime and to add it to the sum. if the result of dividend-quotient*divisor is 0 then i want the program to skip that number and not add it to the sum.

- 07-01-2010, 02:52 AMNorm
Are you able to understand the following request:

Try debugging your code by printing out each number it tests and show whether that number is prime or not.

Also print out the values of the quotient, divisor and dividend.