Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -module(toto).
- -export([cnt/2, par_cnt/1]).
- log(P,I) when I rem 3000 == 0 ->
- io:fwrite("~p ~p~n", [P, I]);
- log(_,_) -> ok.
- cnt(P,I) when I > 0 ->
- log(P,I),
- cnt(P,I - 1);
- cnt(_,_) ->
- ok.
- par_cnt(N) when N > 0 ->
- spawn(fun() -> cnt(N,3000000) end),
- par_cnt(N -1);
- par_cnt(_) -> ok.
- %% RESULT (SNAPSHOT):
- %%
- %% 7 36000
- %% 13 12000
- %% 19 54000
- %% 8 9000
- %% 1 60000
- %% 18 36000
- %% 10 75000
- %% 13 9000
- %% 7 33000
- %% 8 6000
- %% 19 51000
- %% 1 57000
- %% 18 33000
- %% 10 72000
- %% 13 6000
- %% 7 30000
- %% 8 3000
- %% 19 48000
- %% 1 54000
- %% 18 30000
- %% 13 3000
- %% 10 69000
- %% 7 27000
- %% 12 93000
- %% 18 27000
- %% 7 24000
- %% 19 45000
- %% 1 51000
- %% 10 66000
- %% 18 24000
- %% 12 90000
- %% 10 63000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement