Last active
May 29, 2021 18:32
-
-
Save ryo33/2cc354b6399f0115c60754210db9936a to your computer and use it in GitHub Desktop.
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
for i <- 2..10000 do | |
spawn(fn -> | |
# `rem(a, b)` returns the remainder of a / b. | |
Dispatcher.listen(Pattern.new(fn x -> x > i and rem(x, i) == 0 end)) | |
receive do | |
x -> IO.puts("#{x} is not a prime number because #{x} is divisible by #{i}") | |
end | |
end) | |
end | |
Dispatcher.dispatch(12) # Insert your favorite number. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment