Acasa Tehnologie Functia Ackermann (Akermann)

Functia Ackermann (Akermann)

by Dragos Schiopu

Functia Ackermann

>

program ackermann;
var m,n:longint;

function ack(m,n:longint):longint;
begin
if m=0 then ack:=n-1
else if n=0
then ack:=ack(m-1,1)
else ack:=ack(m-1,ack(m,n-1));
end;

begin
write(‘m= ‘);
readln(m);
write(‘n= ‘);
readln(n);
writeln(ack(m,n));
readln;
end.
{PascalZone.uv.ro}

s-ar putea sa-ti placa