Advertisement
paulogp

Factorial

Aug 7th, 2011
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.61 KB | None | 0 0
  1. { paulogp }
  2. { mac os 7 }
  3. program Ada05p;
  4.  
  5. uses
  6.     MemTypes, QuickDraw, OSIntf;  
  7.  
  8. Var
  9.     i, n, fact: integer;
  10.     fim: string;
  11.  
  12. begin
  13.     repeat
  14.         clearscreen;
  15.         writeln('Programa: Cálculo de factoriais!');
  16.         repeat
  17.             writeln;
  18.             if n < 0 then write('Introduza o valor de N (POSITIVO): ') else
  19.             write('Introduza o valor de N: ');
  20.             readln(n);
  21.         until n >= 0;
  22.         fact:= 1;
  23.         for i:= n downto 1 do fact:= fact * i;
  24.         writeln;                          
  25.         writeln(n,'! = ', fact);  
  26.         writeln;
  27.         writeln;
  28.         write('Repetir programa (S/N): ');
  29.         readln(fim);
  30.         uprstring(fim, true);
  31.     until fim = 'N';
  32. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement