Advertisement
Guest User

lottery4

a guest
Sep 22nd, 2010
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 0.38 KB | None | 0 0
  1. uniform() ->
  2.     {A1, A2, A3} = case get(random_seed) of
  3.                undefined -> seed0();
  4.                Tuple -> Tuple
  5.            end,
  6.     B1 = (A1*171) rem 30269,
  7.     B2 = (A2*172) rem 30307,
  8.     B3 = (A3*170) rem 30323,
  9.     put(random_seed, {B1,B2,B3}),
  10.     R = A1/30269 + A2/30307 + A3/30323,
  11.     R - trunc(R).
  12.  
  13. uniform(N) when is_integer(N), N >= 1 ->
  14.     trunc(uniform() * N) + 1.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement