Skip to content

Instantly share code, notes, and snippets.

@ming2540
Created August 31, 2018 06:18
Show Gist options
  • Save ming2540/a1082c11b9ad91222bc522863d298ca3 to your computer and use it in GitHub Desktop.
Save ming2540/a1082c11b9ad91222bc522863d298ca3 to your computer and use it in GitHub Desktop.
#include<stdio.h>
int factorial(int n){
int i;
int answer=1;
for(i=n;i>=1;i--){
answer = answer*i;
}
return answer;
}
int main(){
printf("factorial of 5 is %d", factorial(5));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment