Advertisement
FoxTuGa

Factorial - <Old>

May 8th, 2011
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. long long int n, x, nt;
  5.  
  6. // Principal.
  7. int main()
  8. {
  9.     /*Loop infinito para o utilizador fazer multiplas contas*/
  10.     while(1)
  11.     {
  12.         printf("\n\n\tIntroduza um Numero: ");
  13.         fflush(stdin);      //Passar todas as letras a 0.      
  14.         scanf("%lld", &n);      //Inputs dos valores
  15.         system("cls");      //Limpar o ecran Após os dados serem introduzidos
  16.        
  17.         /*Loop que efectua as contas*/
  18.         for(x=n;x>0;x--)
  19.             nt+=x;
  20.  
  21.         printf("\n\n %lld! = %lld", n, nt); // Output dos valores
  22.         nt=0; //Limpar a variavel "nt"
  23.     }
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement