Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Prime number test
#2
Simple but slow.
Function IsPrimeNumber
Code:
Copy      Help
;/
function! x

if(x<2) ret

int i si=sqrt(x)+1
for i 2 si
,if !(x%i)
,,;out "%i is divisible by %i" x i
,,ret

;out "%i is prime number" x
ret 1


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)