Skip to content

Commit

Permalink
Increased Range of factorial
Browse files Browse the repository at this point in the history
Taking unsigned long long in place of long long doubles the domain of calculating factorial.
  • Loading branch information
adityauser authored Oct 30, 2017
1 parent e350526 commit 688fb5c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions math/factorial/C/factorial.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include<stdio.h>

long long fact(long long x)
unsigned long long fact(unsigned long long x)
{
if(x > 1)
return x*fact(x-1);
Expand All @@ -9,9 +9,9 @@ long long fact(long long x)

int main(void)
{
int n, t, s=0, r;
unsigned int n, t, s=0, r;
printf("Enter the number: ");
scanf("%d", &n);
printf("\nFactorial of the number is: %lld",fact(n));
scanf("%u", &n);
printf("\nFactorial of the number is: %llu",fact(n));
return 0;
}
}

0 comments on commit 688fb5c

Please sign in to comment.