Rabu, 22 Oktober 2014

Tugas 3

Dalam Bahasa Pascal:

uses crt;
Var
        x:Integer;
        Y:Integer;
        z:Integer;
        A:Integer;
BEGIN
        CLRSCR;
        WRITELN('Faktorial Dari: ');READLN(X);
        Z:=1;
        for y:= X downto 1 do
        Begin
                Z:=Z*Y;
                IF Y = 1 Then
                        Begin
                        WRITE(Y);WRITE(' = ');WRITE(Z);
                        End
                Else
                        WRITE(Y,'*');

        END;
        READLN();
End.
Dalam Bahasa Algoritma:
Var
        x:Integer
        Y:Integer
        z:Integer
        A:Integer
BEGIN
        CLRSCR
        Output('Faktorial Dari: ')Input(X)
        Z-->1
        for y--> X downto 1 do
        Begin
                Z-->Z*Y
                IF Y = 1 Then
                        Begin
                        Output(Y);Output(' = ');Output(Z);
                        End
                Else
                        Output(Y,'*')

        END
       
End Algoritma

Tidak ada komentar:

Posting Komentar