Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. -module(toto).
  2. -export([cnt/2, par_cnt/1]).
  3.  
  4. log(P,I) when I rem 3000 == 0 ->
  5. io:fwrite("~p ~p~n", [P, I]);
  6. log(_,_) -> ok.
  7.  
  8. cnt(P,I) when I > 0 ->
  9. log(P,I),
  10. cnt(P,I - 1);
  11. cnt(_,_) ->
  12. ok.
  13.  
  14. par_cnt(N) when N > 0 ->
  15. spawn(fun() -> cnt(N,3000000) end),
  16. par_cnt(N -1);
  17. par_cnt(_) -> ok.
  18.  
  19.  
  20. %% RESULT (SNAPSHOT):
  21. %%
  22. %% 7 36000
  23. %% 13 12000
  24. %% 19 54000
  25. %% 8 9000
  26. %% 1 60000
  27. %% 18 36000
  28. %% 10 75000
  29. %% 13 9000
  30. %% 7 33000
  31. %% 8 6000
  32. %% 19 51000
  33. %% 1 57000
  34. %% 18 33000
  35. %% 10 72000
  36. %% 13 6000
  37. %% 7 30000
  38. %% 8 3000
  39. %% 19 48000
  40. %% 1 54000
  41. %% 18 30000
  42. %% 13 3000
  43. %% 10 69000
  44. %% 7 27000
  45. %% 12 93000
  46. %% 18 27000
  47. %% 7 24000
  48. %% 19 45000
  49. %% 1 51000
  50. %% 10 66000
  51. %% 18 24000
  52. %% 12 90000
  53. %% 10 63000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement