Skip to content

Instantly share code, notes, and snippets.

@kalimalrazif
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kalimalrazif/784e2504cfe0f9f55540 to your computer and use it in GitHub Desktop.
Save kalimalrazif/784e2504cfe0f9f55540 to your computer and use it in GitHub Desktop.
Ejemplo de Iteratividad, factorial
#include <stdio.h>
double factorial(int);
int main(){
int numero = 5;
double total;
total = factorial(numero);
printf("El factorial de %d es %d\n", numero, total);
return 0;
}
double factorial(int nro){
double total=1
int i;
for(i=nro;i>0; i--){
total=total*i; // Otra manera de escribir esto es: total *=i;
}
return total;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment