code_junkie

Ruby isPrime Method

Nov 11th, 2011
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.15 KB | None | 0 0
  1. ('1' * N) !~ /^1?$|^(11+?)1+$/
  2.  
  3. require 'mathn'
  4. 38749711234868463.prime?
  5. => false
  6.  
  7. /^(1+)1*=1+$/.match('1' * x + '=' + '1' * y)[1].length
Add Comment
Please, Sign In to add comment