Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
Loading...
Searching...
No Matches
check_factorial.cpp File Reference

A simple program to check if the given number is a factorial of some number or not. More...

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

Namespaces

namespace  math
 for IO operations
 

Functions

bool math::is_factorial (uint64_t n)
 Function to check if the given number is factorial of some number or not.
 
static void tests ()
 Self-test implementations.
 
int main ()
 Main function.
 

Detailed Description

A simple program to check if the given number is a factorial of some number or not.

A factorial number is the sum of k! where any value of k is a positive integer. https://www.mathsisfun.com/numbers/factorial.html

Author
Divyajyoti Ukirde
ewd00010

Function Documentation

◆ main()

int main ( void )

Main function.

Returns
0 on exit
70 {
71 tests(); // run self-test implementations
72 return 0;
73}
static void tests()
Self-test implementations.
Definition check_factorial.cpp:55
Here is the call graph for this function:

◆ tests()

static void tests ( )
static

Self-test implementations.

Returns
void
55 {
56 assert(math::is_factorial(50) == false);
57 assert(math::is_factorial(720) == true);
58 assert(math::is_factorial(0) == false);
59 assert(math::is_factorial(1) == true);
60 assert(math::is_factorial(479001600) == true);
61 assert(math::is_factorial(-24) == false);
62
63 std::cout << "All tests have successfully passed!" << std::endl;
64}
T endl(T... args)
bool is_factorial(uint64_t n)
Function to check if the given number is factorial of some number or not.
Definition check_factorial.cpp:27
Here is the call graph for this function: