fnplus / interview-techdev-guide

This repository contains curated technical interview questions by fn+geeks community
http://bit.ly/fnplusnow
MIT License
318 stars 325 forks source link

Implemented factorial in C. #613

Open roeey777 opened 4 years ago

roeey777 commented 4 years ago

Signed-off-by: Eyal Royee eyalroyee@gmail.com

xlogix commented 4 years ago

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

poojapatidar21 commented 4 years ago

include 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; }