my $M = 8; my $A = 5; my $X = 0; sub lcrng { $X = (($X * $A) + 1) % $M; return ($X); }