Advertisement
janducev

Untitled

Oct 21st, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int CalculaFactorial(int numero){
  5. int salida = 1;
  6. printf("El factorial de %d = ",numero);
  7. for(int i=numero;i>0;i--){
  8. printf("%d x",i);
  9. salida = salida * i;
  10. }
  11.  
  12. printf("\b\b %d\n",salida);
  13. return salida;
  14. }
  15.  
  16. int main () {
  17.  
  18. int tmp;
  19. int factorial;
  20.  
  21.  
  22. printf("Dame 1 numero\n");
  23. scanf("%d",&tmp);
  24. getchar();
  25.  
  26. factorial = CalculaFactorial(tmp);
  27.  
  28. printf("El factorial de %d es %d\n",tmp,factorial);
  29.  
  30. getchar();
  31. return(0);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement