A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/d9/d00/factorial_8cpp.html below:

TheAlgorithms/C++: math/factorial.cpp File Reference

Loading...

Searching...

No Matches

Find the factorial of a given number. More...

#include <cassert>
#include <cstdint>
#include <iostream>

Go to the source code of this file.

namespace   math   for assert
uint64_t  math::factorial (uint8_t n)   function to find factorial of given number
static void  tests ()   Self-test implementations.
int  main ()   Main function.

Find the factorial of a given number.

Calculate factorial via recursion

\[n! = n\times(n-1)\times(n-2)\times(n-3)\times\ldots\times3\times2\times1 = n\times(n-1)!\]

for example: \(5! = 5\times4! = 5\times4\times3\times2\times1 = 120\)

Definition in file factorial.cpp.

◆ main()

Main function.

Returns
0 on exit

Definition at line 57 of file factorial.cpp.

57 {

59 return 0;

60}

static void tests()

Self-test implementations.

◆ tests()

Self-test implementations.

Returns
void

Definition at line 44 of file factorial.cpp.

44 {

50 std::cout << "All tests have passed successfully!\n";

51}

uint64_t factorial(uint8_t n)

function to find factorial of given number


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4