Skip to content

Instantly share code, notes, and snippets.

/static_ruby.rb Secret

Created April 8, 2016 15:14
Show Gist options
  • Save anonymous/64a2cc1ee4de1855b8b9314c5b201f4c to your computer and use it in GitHub Desktop.
Save anonymous/64a2cc1ee4de1855b8b9314c5b201f4c to your computer and use it in GitHub Desktop.
static vars
class Prime
@@start=2; def is_prime? num; flag = true; while ( @@start < num ); begin;flag = false; break;end if num % @@start == 0; @@start+=1;end;flag; end
end
pr = Prime.new; [*1..10].map { |i| Thread.new { p i.to_s + pr.is_prime?(i).to_s } }.each(&:join)
"2true"
"1true"
"3true"
"4true"
"5true"
"6true"
"8true"
"10true"
"9true"
"7true"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment