Ember

prime

Oct 28th, 2013
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Returns if a number is prime or not
  2. var Divisor;
  3.  
  4. // Loop through all divisible values of the number
  5. for(Divisor = 2; Divisor <= floor(sqrt(argument0)); Divisor += 1;)
  6. {
  7.     // See if the number is divisible by the divisor
  8.     if(argument0 mod Divisor == 0)
  9.     {
  10.         // Return the number this is divisible by
  11.         return Divisor;
  12.     }
  13. }
  14.  
  15. // This number is prime
  16. return 1;
Advertisement
Add Comment
Please, Sign In to add comment