Find a number is prime or not
Solution:
q)isPrime:{ $[x~2;1b;0~x mod 2;0b;x<1;0b;2=count where 0=( x mod ) each til x+1]
}
returns:
false for all negative numbers, 0 and 1
Find a number is prime or not
Solution:
q)isPrime:{ $[x~2;1b;0~x mod 2;0b;x<1;0b;2=count where 0=( x mod ) each til x+1]
}
returns:
false for all negative numbers, 0 and 1