factorial of n (n!) = 1 * 2 * 3 * 4....n
C
xxxxxxxxxx
int main() {
int n, i;
unsigned long long fact = 1;
printf("Enter an integer: ");
scanf("%d", &n);
// shows 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) {
fact *= i;
}
printf("Factorial of %d = %llu", n, fact);
}
return 0;
}
Enter an integer: 10 Factorial of 10 = 3628800
Linux - How to Install anc-api-tools
Linux - How to Install curvedns
Python - Check if a Number is Positive, Negative or 0
Linux - How to Install zenmap
C - Count Number of Digits in an Integer
C++ - Check Leap Year
JavaScript - Check Whether a String Starts and Ends With Certain Characters
C++ - Check Whether a Number is Prime or Not
C - Find Largest Number Using Dynamic Memory Allocation
Kotlin - Round a Number to n Decimal Places
Kotlin - Reverse a Number
Linux - How to Install xbitmaps
Linux - How to Install zstd
Linux - How to Install zfs-test
Java - Reverse a Number
Python - Writing Excel (XLSX) Files
C++ - Find Quotient and Remainder
Linux - How to Install zookeeper-bin
We have been online since 2021 and 1 millions of people around the globe have visited our website since then
More visitors every month