I never got back to you to say thanks, was able to figure it out. :)
: : Hey all, I'm on an assignment and a bit lost. I'm supposed to write a program that finds the average of all prime numbers between 1 and 100 and prints this average to screen:
: :
: :
: : I can do it all easily enough, except for finding prime numbers.. I suspect it's something to do with the modulas (remainder) operator but not real sure how to lay it out, any help is appreciated guys & gals. ^^
: :
:
: Here's an easy (and fast) algorithm (pen and paper implementation;) for finding primes up to a certian number:
:
:
: // I don't know if 1 is a prime number, so we'll skip it ;)
: write down the numbers from 2 to lets say 100.
: put a circle around 2 and cross out all higher multiples of 2 (4, 6, 8 etc)
: while there are numbers without a circle or a cross:
: {
: find the next noncrossed number and put a circle around it, and cross out all higher multiples of this number
: }
: all numbers with circles around them are prime
:
:
: good luck,
: Pruyque
: