Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Prime number test
#10
I found:

Function IsPrimeNumber3
Code:
Copy      Help
function int'n

if(n=1) ret 0
if(n<4) ret 1
if(n%2=0) ret 0
if(n<9) ret 1
if(n%3=0) ret 0
int r=sqrt(n)
int f=5
;bucle
if(f<=r)
,if((n%f)=0) ret 0
,if(n%(f+2)=0) ret 0
,f+6
,goto bucle
ret 1

Do you know why IsPrimeNumber3 is slower than IsPrimeNumber2?


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)