interview-techdev-guide
interview-techdev-guide copied to clipboard
Implemented factorial in C.
It would be great if you can add the description along with the issue number. Feel free to use our contribution guidelines (https://github.com/fnplus/interview-techdev-guide/blob/master/CONTRIBUTING.md#how-to-contribute-an-implementation-code) for reference
include <stdio.h>
int main()
{
int n, i;
unsigned long long factorial = 1;
printf("Enter an integer: ");
scanf("%d",&n);
if (n < 0)
printf("Factorial of a negative number doesn't exist.");
else
{
for(i=1; i<=n; ++i)
{
factorial *= i;
}
printf("Factorial of %d = %llu", n, factorial);
}
return 0;
}