Welcome~~~


Another blog:
http://fun-st.blogspot.com/

It is easier to write an incorrect program than understand a correct one.

Saturday, February 12, 2011

# Check if prime numbers

Loop thro the list ,
for(i=2,i<=Math.sqrt(num);i++)
if(num%i==0)
not prime

note that since 2, 3, 5 takes a lot of spots, it would be better to first check:

 if((number % 2) == 0 || (number % 3) == 0) || (number % 5) == 0 )

♥ ¸¸.•*¨*•♫♪♪♫•*¨*•.¸¸♥
http://www.glassdoor.com/Interview/Write-the-program-to-return-a-list-of-specified-prime-numbers-QTN_112834.htm
http://code.activestate.com/recipes/366178/
http://code.activestate.com/recipes/410662-a-function-to-check-if-a-number-is-prime/
http://www.codingforums.com/showthread.php?t=55576
http://stackoverflow.com/questions/1538644/c-determine-if-a-number-is-prime

No comments:

Post a Comment