Algorithms_in_C++  1.0.0
Set of algorithms implemented in C++.
factorial.cpp File Reference

C++ program to find factorial of given number. More...

#include <iostream>
Include dependency graph for factorial.cpp:

Functions

unsigned int factorial (unsigned int n)
 
int main ()
 

Detailed Description

C++ program to find factorial of given number.

Function Documentation

◆ factorial()

unsigned int factorial ( unsigned int  n)

function to find factorial of given number

8  {
9  if (n == 0)
10  return 1;
11  return n * factorial(n - 1);
12 }

◆ main()

int main ( void  )

Main function

15  {
16  int num = 5;
17  std::cout << "Factorial of " << num << " is " << factorial(num)
18  << std::endl;
19  return 0;
20 }
Here is the call graph for this function:
std::cout
std::endl
T endl(T... args)
factorial
unsigned int factorial(unsigned int n)
Definition: factorial.cpp:8