krot

is_prime

Jul 20th, 2020
1,093
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. is_prime(N)->is_prime(N,2,erlang:trunc(math:sqrt(N))).
  2.  
  3. is_prime(1,_X,_E)->false;
  4. is_prime(2,_X,_E)->true;
  5. is_prime(N,X,_E) when N rem X ==0->false;
  6. is_prime(N,X,E) when X =< E->is_prime(N,X+1,E);
  7. is_prime(_N,_X,_E)->true.
RAW Paste Data