Simple Recursive Factorial Function Using a Native Type in C/C++
#include<iostream> // Simple recursive factorial using a native type (unsigned long long).// Note: overflow for n > 20 on 64-bit unsigned long long.unsigned long long fact_recursive(unsigned n) {return (n <= 1) ? 1ULL : n * fact_recursive(n – 1);} int main() {unsigned n;std::cout << “Enter a non-negative integer: “; if (!(std::cin >> n)) return 1; […]
Simple Recursive Factorial Function Using a Native Type in C/C++ Read More »