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/db/d9f/iterative__factorial_8cpp_source.html below:

TheAlgorithms/C++: math/iterative_factorial.cpp Source File

Go to the documentation of this file. 49 throw

std::invalid_argument(

"Maximum n value is 20"

);

53

uint64_t accumulator = 1;

71

std::cout <<

"Exception case test \n" 73 "Expected output: 1 \n\n"

;

77

std::cout <<

"Base case test \n" 79 "Expected output: 1 \n\n"

;

83

std::cout <<

"Small number case test \n" 85 "Expected output: 120 \n\n"

;

89

std::cout <<

"Medium number case test \n" 91 "Expected output: 3628800 \n\n"

;

95

std::cout <<

"Maximum case test \n" 97 "Expected output: 2432902008176640000\n\n"

;

101

std::cout <<

"Exception test \n" 103 "Expected output: Exception thrown \n"

;

105 bool

wasExceptionThrown =

false

;

108

}

catch

(

const

std::invalid_argument&) {

109

wasExceptionThrown =

true

;

111

assert(wasExceptionThrown);

113

std::cout <<

"All tests have passed successfully.\n"

;

static void test()

Self-test implementations to test iterativeFactorial function.

int main()

Main function.

uint64_t iterativeFactorial(uint8_t n)

Calculates the factorial iteratively.


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