Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 15th, 2012  |  syntax: C  |  size: 0.35 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include<stdio.h>
  2. int factorial(int n)
  3. {
  4.   if(n<2)
  5.     return 1;
  6.   else
  7.     return n * factorial(n-1);
  8. }
  9. int main()
  10. {
  11.   int num=0;
  12.   printf("::CALCULAR FACTORIAL::\n");
  13.   printf("Introduce un numero: ");scanf("%i",&num); //Pedir variable num
  14.   printf("\tEl resultado es: %i\n", factorial(num)); //Llama la funcion e imprime resultado
  15.   return 0;
  16. }