IDNLearn.com: Where your questions are met with thoughtful and precise answers. Get the information you need quickly and accurately with our reliable and thorough Q&A platform.
Answer:
#include <iostream>
int factorial(int n) {
return (n > 1) ? n*factorial(n-1) : 1;
}
int main() {
std::cout << factorial(5);
}
Explanation:
Above is an approach using recursion.
It will output 120, which is 5! = 5*4*3*2*1