Niezalogowany (Zaloguj się)
WItaj Gościu! Możesz się teraz zalogować lub poprosić o członkowstwo na Forum Turbo Pascal Web Pag
    • CommentAuthorkrzysio-k9
    • CommentTime1 Mar 2010 zmieniony
     
    Mam zrobić rekurencję i funkcję z tego programu. Co mam w nim źle.

    program silnia;
    uses crt;
    var
    n,s,i:integer;

    begin
    function silnia(n:integer):integer;
    begin

    silnia:=1
    writeln('podaj n');
    readln(n);
    if n<0 then

    writeln ('n nie moze byc mniejsze od 0')

    else
    begin

    if n=0 then
    writeln('silnia',silnia)
    else
    begin

    for i:=1 to n do
    silnia:=silnia*i;
    silnia(n) = silnia(n-1) * n; silnia(0) = 1;

    {
    if (n == 0)
    return 1;
    else
    return silnia(n-1) * n;
    }
    writeln('silnia',silnia);

    readkey;
    end;
    end;
    end.