Skip to content

Instantly share code, notes, and snippets.

@anonur
Last active April 4, 2019 19:04
Show Gist options
  • Save anonur/1da752a84b798cd1bc4bbc12ce514f5f to your computer and use it in GitHub Desktop.
Save anonur/1da752a84b798cd1bc4bbc12ce514f5f to your computer and use it in GitHub Desktop.
Simple code for finding a factorial
#include<stdio.h>
int main()
{
int n;
int fact = 1;
printf("Enter an integer that you want to take the factorial of: ");
scanf("%d",&n);
while(n != 0) {
printf("%d\n",n);
fact = fact * n;
n --;
}
printf("%d",fact);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment