Tugger the SLUGger!SLUG Mailing List Archives

Re: [SLUG] c++... a bit OT

This one time, at band camp, Alex Salmon said:

>what do u mean by that exactly 3 to sqrt(x) by 2... what is x 

if (num % 2 == 1) {
	for (i = 3; i <= sqrt(num); i+=2) {

He means, check for oddness, then go from 3 to the square root of the
number you're checking, in steps of 2.

>my idea was that as all primes end in 1,3,7,9 (not all ending 1 3 7 9 are
>primes tho)

Yeah, I stand corrected on that. feh, logic.  I'm still playing with
kernel-package on Debian, and logic doesn't seem to apply here.

>James said somthing about doing everything in binary. what would be the
>actually outcome of this i mean how could i extract the last digit and set
>it to a int to test it as such??

I was thinking, that as computers are binary machines, you could
probably speed up your algorithm by thinking in binary rather than
decimal.  This will mean doing a lot of modification to your algorithm.
Just thinking out loud again.

     Sure, I subscribe to USENET, but I only get it for the articles.
(o_ '