Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% fib2.erl
- -module(fib2).
- -export([fib/1]).
- fib(0) -> 0;
- fib(1) -> 1;
- fib(N) ->
- fib2(N - 1) + fib(N - 2).
- fib2(N) ->
- Pid = spawn(fun worker/0),
- Pid ! {self(), N},
- receive
- F -> F
- end.
- worker() ->
- receive
- {From, N} -> From ! fib(N)
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement