0
Program random_no (input, output) ;
Const m=100000000; m1=10000; q=31415821;
Var i, p, No: integer;
function mult(r, s: integer) : integer;
        Var r1, r0,s1,s0: integer;
        begin
        r1 :=r div m1 ; r0:=r mod m1 ;
        s1 :=s div m1; s0:=s mod m1;
        mult:=( ((r0*s1+r1*s0) mod m1)*m1+r0*s0)
        end ;
function random : integer ;
        begin
        p:=(mult(p, q)+1) mod m;
        random :=p;
        end ;
begin
read(No, p);
for i:=1 to No do writeln(random)
end.

Quoted Text Here
Hey guys i need help to debug this code care to lend a hand?

Edited by deceptikon: Moved to the Pascal forum

2
Contributors
1
Reply
3
Views
5 Years
Discussion Span
Last Post by deceptikon
1

Given that the code was pinched verbatim from this article, my initial question is why do you think it needs debugging in the first place? Does it not work? That's somewhat likely, but I'd like to believe the article's author wouldn't publish untested code. Or does it just do something different than you wanted?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.