mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-02-03 18:46:50 +08:00
documented factorial
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
// C++ program to find factorial of given number
|
||||
#include<iostream>
|
||||
/**
|
||||
* @file
|
||||
* @brief C++ program to find factorial of given number
|
||||
*/
|
||||
#include <iostream>
|
||||
|
||||
// function to find factorial of given number
|
||||
/** function to find factorial of given number */
|
||||
unsigned int factorial(unsigned int n) {
|
||||
if (n == 0)
|
||||
return 1;
|
||||
return n * factorial(n - 1);
|
||||
}
|
||||
|
||||
// Driver code
|
||||
/** Main function */
|
||||
int main() {
|
||||
int num = 5;
|
||||
std::cout << "Factorial of " << num << " is " << factorial(num)
|
||||
|
||||
Reference in New Issue
Block a user