Skip to content

Commit

Permalink
commit 1
Browse files Browse the repository at this point in the history
factorial ka github first attempt
  • Loading branch information
balajikatakam authored Mar 30, 2017
1 parent a56924f commit fee5410
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions factorial
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <stdio.h>
int main()
{
int n, i;
unsigned long long factorial = 1;

printf("Enter an integer: ");
scanf("%d",&n);

// show error if the user enters a negative integer
if (n < 0)
printf("Error! Factorial of a negative number doesn't exist.");

else
{
for(i=1; i<=n; ++i)
{
factorial *= i; // factorial = factorial*i;
}
printf("Factorial of %d = %llu", n, factorial);
}

return 0;
}

0 comments on commit fee5410

Please sign in to comment.