Functions.. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Functions..

The built-in or predefined function for finding the factorial of a number is...

9th Aug 2018, 11:02 PM
Dâvë Wøndër
Dâvë Wøndër - avatar
1 Answer
+ 2
The factorial of a number is the product of all the Integers (int) from 1 to that number.! Examp: #include<iostream> using namespace std; int factorial(int n); int main() { int n; cout << "Enter a positive integer: "; cin >> n; cout << "Factorial of " << n << " = " << factorial(n); return 0; } int factorial(int n) { if(n > 1) return n * factorial(n - 1); else return 1; } ---------------------------- Output : Enter an positive integer: 6 Factorial of 6 = 720
10th Aug 2018, 1:17 AM
Imade Andika Suwartama
Imade Andika Suwartama - avatar