Skip to content

Instantly share code, notes, and snippets.

@ryo33
Last active May 29, 2021 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryo33/2cc354b6399f0115c60754210db9936a to your computer and use it in GitHub Desktop.
Save ryo33/2cc354b6399f0115c60754210db9936a to your computer and use it in GitHub Desktop.
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