-
-
Save anonymous/64a2cc1ee4de1855b8b9314c5b201f4c to your computer and use it in GitHub Desktop.
static vars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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