ronantakizawa/codereview-bench huggingface dataset:
Repository: TheAlgorithms/C-Plus-Plus
File: math/quadratic_equations_complex_numbers.cpp (C++)

Code before:
/**
 * @file
 * @brief Calculate quadratic equation with complex roots, i.e. b^2 - 4ac < 0.
 * @see https://en.wikipedia.org/wiki/Quadratic_equation,
 * https://en.wikipedia.org/wiki/Quadratic_equation#discriminant
 *
 * @author [Renjian-buchai](https://github.com/Renjian-buchai)
 */

#include <array>
#include <cassert>
#include <cmath>
#include <complex>
#include <exception>
#include <iomanip>
#include <iostream>

/// @brief Quadratic equation calculator.
/// @param a quadratic coefficient.
/// @param b linear coefficient.
/// @param c constant
/// @return Array containing the roots of quadratic equation, incl. complex
/// root.
std::array<std::complex<long double>, 2> quadraticEquation(long double a,
                                                           long double b,
                                                           long double c) {
    /**
     * Calculates any quadratic equation in form ax^2 + bx + c.
     *
     * Quadratic equation:
     * x = (-b +/- sqrt(b^2 - 4ac)) / 2a
     *
     * e.g.
     * using namespace std;
     * int main() {
     *   array<complex<long double, 2> solutions = quadraticEquation(1, 2, 1);
     *   cout << solutions[0] << " " << solutions[1] << "\n";
     *
     *   solutions = quadraticEquation(1, 1, 1);  // Reusing solutions.
     *   cout << solutions[0] << " " << solutions[1] << "\n";
     *   return 0;
     * }
     *
     * Output:
     * (-1, 0) (-1, 0)
     * (-0.5,0.866025) (-0.5,0.866025)
     */


Review comment (performance):
```suggestion
/**
 * @brief Quadratic equation calculator.
 * @param a quadratic coefficient.
 * @param b linear coefficient.
 * @param c constant
 * @return Array containing the roots of quadratic equation, incl. complex
 * root.
 */ 
```
Multi line is preferred for documentation 

Code after:
/**
 * @file
 * @brief Calculate quadratic equation with complex roots, i.e. b^2 - 4ac < 0.
 *
 * @author [Renjian-buchai](https://github.com/Renjian-buchai)
 *
 * @description Calculates any quadratic equation in form ax^2 + bx + c.
 *
 * Quadratic equation:
 * x = (-b +/- sqrt(b^2 - 4ac)) / 2a
 *
 * @example
 * int main() {
 *   using std::array;
 *   using std::complex;
 *   using std::cout;
 *
 *   array<complex<long double, 2> solutions = quadraticEquation(1, 2, 1);
 *   cout << solutions[0] << " " << solutions[1] << "\n";
 *
 *   solutions = quadraticEquation(1, 1, 1);  // Reusing solutions.
 *   cout << solutions[0] << " " << solutions[1] << "\n";
 *   return 0;
 * }
 *
 * Output:
 * (-1, 0) (-1, 0)
 * (-0.5,0.866025) (-0.5,0.866025)
 */

#include <array>      /// std::array
#include <cassert>    /// assert
#include <cmath>      /// std::sqrt, std::trunc, std::pow
#include <complex>    /// std::complex
#include <exception>  /// std::invalid_argument
#include <iomanip>    /// std::setprecision
#include <iostream>   /// std::cout

/**
 * @namespace
 * @brief Mathematical algorithms
 */
namespace math {

/**
 * @brief Quadratic equation calculator.
 * @param a quadratic coefficient.
 * @param b linear coefficient.
Repository: TheAlgorithms/C-Plus-Plus
File: math/quadratic_equations_complex_numbers.cpp (C++)

Code before:
    }

    return solutions;
}

static void test() {
    std::array<std::complex<long double>, 2> realCase{
        std::complex<long double>{1, 0}, std::complex<long double>{1, 0}};
    assert(quadraticEquation(1, -2, 1) == realCase);

    std::array<std::complex<long double>, 2> complexCase{
        std::complex<long double>{-2, -1}, std::complex<long double>{-2, 1}};
    assert(quadraticEquation(1, 4, 5) == complexCase);

    return;
}

int main() {
    test();

    std::array<std::complex<long double>, 2> aaa = quadraticEquation(1, 1, 1);
    std::cout << "The complex roots of x^2 + x + 1 are " << aaa[0] << " and "
              << aaa[1]
              << ".\nMore precisely, and with the inaccuracy of floating point "
                 "numbers, "
              << std::setprecision(100) << aaa[0] << " and " << aaa[1] << "\n";

    return 0;
}


Review comment (suggestion):
```suggestion
```
would prefer if main functions are left alone and more tests be added instead.

Code after:
    if (discriminant > 0) {
        // Since discriminant > 0, there are only real roots. Therefore,
        // imaginary component = 0.
        solutions[0] = std::complex<long double>{
            (-b - std::sqrt(discriminant)) * 0.5 / a, 0};
        solutions[1] = std::complex<long double>{
            (-b + std::sqrt(discriminant)) * 0.5 / a, 0};
        return solutions;
    }
    // Since b^2 - 4ac is < 0, for faster computation, -discriminant is
    // enough to make it positive.
    solutions[0] = std::complex<long double>{
        -b * 0.5 / a, -std::sqrt(-discriminant) * 0.5 / a};
    solutions[1] = std::complex<long double>{
        -b * 0.5 / a, std::sqrt(-discriminant) * 0.5 / a};

    return solutions;
}

}  // namespace math

/**
 * @brief Asserts an array of complex numbers.
 * @param input Input array of complex numbers. .
 * @param expected Expected array of complex numbers.
 * @param precision Precision to be asserted. Default=10
 */
void assertArray(std::array<std::complex<long double>, 2> input,
                 std::array<std::complex<long double>, 2> expected,
                 size_t precision = 10) {
    long double exponent = std::pow(10, precision);
    input[0].real(std::round(input[0].real() * exponent));
    input[1].real(std::round(input[1].real() * exponent));
    input[0].imag(std::round(input[0].imag() * exponent));
    input[1].imag(std::round(input[1].imag() * exponent));

    expected[0].real(std::round(expected[0].real() * exponent));
    expected[1].real(std::round(expected[1].real() * exponent));
    expected[0].imag(std::round(expected[0].imag() * exponent));
    expected[1].imag(std::round(expected[1].imag() * exponent));

    assert(input == expected);
}

/**
 * @brief Self-test implementations to test quadraticEquation function.
 * @note There are 4 different types of solutions: Real and equal, real,
 * complex, complex and equal.
 */
static void test() {
    // Values are equal and real.
Repository: TheAlgorithms/C-Plus-Plus
File: math/quadratic_equations_complex_numbers.cpp (C++)

Code before:
/**
 * @file
 * @brief Calculate quadratic equation with complex roots, i.e. b^2 - 4ac < 0.
 * @see https://en.wikipedia.org/wiki/Quadratic_equation,
 * https://en.wikipedia.org/wiki/Quadratic_equation#discriminant
 *
 * @author [Renjian-buchai](https://github.com/Renjian-buchai)
 */

#include <array>
#include <cassert>
#include <cmath>
#include <complex>
#include <exception>
#include <iomanip>
#include <iostream>

/// @brief Quadratic equation calculator.
/// @param a quadratic coefficient.
/// @param b linear coefficient.
/// @param c constant
/// @return Array containing the roots of quadratic equation, incl. complex
/// root.
std::array<std::complex<long double>, 2> quadraticEquation(long double a,
                                                           long double b,
                                                           long double c) {
    /**
     * Calculates any quadratic equation in form ax^2 + bx + c.
     *
     * Quadratic equation:
     * x = (-b +/- sqrt(b^2 - 4ac)) / 2a
     *
     * e.g.
     * using namespace std;
     * int main() {
     *   array<complex<long double, 2> solutions = quadraticEquation(1, 2, 1);
     *   cout << solutions[0] << " " << solutions[1] << "\n";
     *
     *   solutions = quadraticEquation(1, 1, 1);  // Reusing solutions.
     *   cout << solutions[0] << " " << solutions[1] << "\n";
     *   return 0;

Review comment (suggestion):
```suggestion
#include <array> /// for arrays
#include <cassert> /// for assert
#include <cmath> /// for common mathematical operations
#include <complex> /// for complex number mathematics
#include <exception> /// for exceptions 
#include <iomanip> /// for I/O parametric manipulations 
#include <iostream> /// for I/O operations
```
Should add explanations for including headers and libraries 

Code after:
/**
 * @file
 * @brief Calculate quadratic equation with complex roots, i.e. b^2 - 4ac < 0.
 *
 * @author [Renjian-buchai](https://github.com/Renjian-buchai)
 *
 * @description Calculates any quadratic equation in form ax^2 + bx + c.
 *
 * Quadratic equation:
 * x = (-b +/- sqrt(b^2 - 4ac)) / 2a
 *
 * @example
 * int main() {
 *   using std::array;
 *   using std::complex;
 *   using std::cout;
 *
 *   array<complex<long double, 2> solutions = quadraticEquation(1, 2, 1);
 *   cout << solutions[0] << " " << solutions[1] << "\n";
 *
 *   solutions = quadraticEquation(1, 1, 1);  // Reusing solutions.
 *   cout << solutions[0] << " " << solutions[1] << "\n";
 *   return 0;
 * }
 *
 * Output:
 * (-1, 0) (-1, 0)
 * (-0.5,0.866025) (-0.5,0.866025)
 */

#include <array>      /// std::array
#include <cassert>    /// assert
#include <cmath>      /// std::sqrt, std::trunc, std::pow
#include <complex>    /// std::complex
#include <exception>  /// std::invalid_argument
#include <iomanip>    /// std::setprecision
#include <iostream>   /// std::cout

/**
 * @namespace
 * @brief Mathematical algorithms
Repository: TheAlgorithms/C-Plus-Plus
File: math/quadratic_equations_complex_numbers.cpp (C++)

Code before:
/**
 * @file
 * @brief Calculate quadratic equation with complex roots, i.e. b^2 - 4ac < 0.
 * @see https://en.wikipedia.org/wiki/Quadratic_equation,
 * https://en.wikipedia.org/wiki/Quadratic_equation#discriminant
 *
 * @author [Renjian-buchai](https://github.com/Renjian-buchai)
 *
 * Calculates any quadratic equation in form ax^2 + bx + c.
 *
 * Quadratic equation:
 * x = (-b +/- sqrt(b^2 - 4ac)) / 2a
 *
 * @example
 * using namespace std;
 * int main() {
 *   array<complex<long double, 2> solutions = quadraticEquation(1, 2, 1);
 *   cout << solutions[0] << " " << solutions[1] << "\n";
 *
 *   solutions = quadraticEquation(1, 1, 1);  // Reusing solutions.
 *   cout << solutions[0] << " " << solutions[1] << "\n";
 *   return 0;
 * }
 *
 * Output:
 * (-1, 0) (-1, 0)
 * (-0.5,0.866025) (-0.5,0.866025)
 */

#include <array>      /// std::array
#include <cassert>    /// assert

Review comment (suggestion):
```suggestion
 * @description
```
Seems like this is a description 


Code after:
/**
 * @file
 * @brief Calculate quadratic equation with complex roots, i.e. b^2 - 4ac < 0.
 *
 * @author [Renjian-buchai](https://github.com/Renjian-buchai)
 *
 * @description Calculates any quadratic equation in form ax^2 + bx + c.
 *
 * Quadratic equation:
 * x = (-b +/- sqrt(b^2 - 4ac)) / 2a
 *
 * @example
 * int main() {
 *   using std::array;
 *   using std::complex;
 *   using std::cout;
 *
 *   array<complex<long double, 2> solutions = quadraticEquation(1, 2, 1);
 *   cout << solutions[0] << " " << solutions[1] << "\n";
 *
 *   solutions = quadraticEquation(1, 1, 1);  // Reusing solutions.
 *   cout << solutions[0] << " " << solutions[1] << "\n";
 *   return 0;
 * }
 *
 * Output:
 * (-1, 0) (-1, 0)
 * (-0.5,0.866025) (-0.5,0.866025)
 */

#include <array>      /// std::array
Repository: TheAlgorithms/C-Plus-Plus
File: math/quadratic_equations_complex_numbers.cpp (C++)

Code before:
                 "(-4.7912878475, 0), (-0.2087121525, 0)\n\n";
    std::array<std::complex<long double>, 2> floatCase{
        std::complex<long double>{-4.7912878475, 0},
        std::complex<long double>{-0.2087121525, 0}};
    assertArray(quadraticEquation(1, 5, 1), floatCase);

    // Values are complex.
    std::cout << "Input: \n"
                 "a=1 \n"
                 "b=1 \n"
                 "c=1 \n"
                 "Expected output: \n"
                 "(-0.5, -0.8660254038), (-0.5, 0.8660254038)\n\n";
    std::array<std::complex<long double>, 2> ifloatCase{
        std::complex<long double>{-0.5, -0.8660254038},
        std::complex<long double>{-0.5, 0.8660254038}};
    assertArray(quadraticEquation(1, 1, 1), ifloatCase);
}

/**
 * @brief Main function
 * @returns 0 on exit
 */
int main() {
    test();  // Run self-test implementation.

    return 0;
}


Review comment (suggestion):
```suggestion
```
This may be a redundant empty line



Code after:
    std::cout << "Input: \n"
                 "a=1 \n"
                 "b=4 \n"
                 "c=5 \n"
                 "Expected output: \n"
                 "(-2, -1), (-2, 1)\n\n";
    std::array<std::complex<long double>, 2> complexCase{
        std::complex<long double>{-2, -1}, std::complex<long double>{-2, 1}};
    assert(math::quadraticEquation(1, 4, 5) == complexCase);

    // Values are real.
    std::cout << "Input: \n"
                 "a=1 \n"
                 "b=5 \n"
                 "c=1 \n"
                 "Expected output: \n"
                 "(-4.7912878475, 0), (-0.2087121525, 0)\n\n";
    std::array<std::complex<long double>, 2> floatCase{
        std::complex<long double>{-4.7912878475, 0},
        std::complex<long double>{-0.2087121525, 0}};
    assertArray(math::quadraticEquation(1, 5, 1), floatCase);

    // Values are complex.
    std::cout << "Input: \n"
                 "a=1 \n"
                 "b=1 \n"
                 "c=1 \n"
                 "Expected output: \n"
                 "(-0.5, -0.8660254038), (-0.5, 0.8660254038)\n\n";
    std::array<std::complex<long double>, 2> ifloatCase{
        std::complex<long double>{-0.5, -0.8660254038},
        std::complex<long double>{-0.5, 0.8660254038}};
    assertArray(math::quadraticEquation(1, 1, 1), ifloatCase);

    std::cout << "Exception test: \n"
                 "Input: \n"
                 "a=0 \n"
                 "b=0 \n"
                 "c=0\n"
                 "Expected output: Exception thrown \n";
    try {
        math::quadraticEquation(0, 0, 0);
    } catch (std::invalid_argument& e) {
        std::cout << "Exception thrown successfully \n";
    }
}

/**
 * @brief Main function
 * @returns 0 on exit
 */
Repository: TheAlgorithms/C-Plus-Plus
File: math/quadratic_equations_complex_numbers.cpp (C++)

Code before:
/**
 * @file
 * @brief Calculate quadratic equation with complex roots, i.e. b^2 - 4ac < 0.
 * @see https://en.wikipedia.org/wiki/Quadratic_equation,
 * https://en.wikipedia.org/wiki/Quadratic_equation#discriminant
 *
 * @author [Renjian-buchai](https://github.com/Renjian-buchai)
 *
 * @description Calculates any quadratic equation in form ax^2 + bx + c.
 *
 * Quadratic equation:
 * x = (-b +/- sqrt(b^2 - 4ac)) / 2a
 *
 * @example
 * using namespace std;
 * int main() {
 *   array<complex<long double, 2> solutions = quadraticEquation(1, 2, 1);
 *   cout << solutions[0] << " " << solutions[1] << "\n";
 *
 *   solutions = quadraticEquation(1, 1, 1);  // Reusing solutions.
 *   cout << solutions[0] << " " << solutions[1] << "\n";
 *   return 0;
 * }
 *
 * Output:
 * (-1, 0) (-1, 0)
 * (-0.5,0.866025) (-0.5,0.866025)
 */

#include <array>      /// std::array

Review comment (suggestion):
`@see` is used for files related to the current algorithm, not for Markdown links.
```suggestion
 * @brief Calculate [Quadratic Qquation](https://en.wikipedia.org/wiki/Quadratic_equation) with complex roots, i.e. b^2 - 4ac < 0.
```


Code after:
/**
 * @file
 * @brief Calculate quadratic equation with complex roots, i.e. b^2 - 4ac < 0.
 *
 * @author [Renjian-buchai](https://github.com/Renjian-buchai)
 *
 * @description Calculates any quadratic equation in form ax^2 + bx + c.
 *
 * Quadratic equation:
 * x = (-b +/- sqrt(b^2 - 4ac)) / 2a
 *
 * @example
 * int main() {
 *   using std::array;
 *   using std::complex;
 *   using std::cout;
 *
 *   array<complex<long double, 2> solutions = quadraticEquation(1, 2, 1);
 *   cout << solutions[0] << " " << solutions[1] << "\n";
 *
 *   solutions = quadraticEquation(1, 1, 1);  // Reusing solutions.
 *   cout << solutions[0] << " " << solutions[1] << "\n";
 *   return 0;
 * }
 *
 * Output:
 * (-1, 0) (-1, 0)
 * (-0.5,0.866025) (-0.5,0.866025)
 */
Repository: TheAlgorithms/C-Plus-Plus
File: math/quadratic_equations_complex_numbers.cpp (C++)

Code before:
/**
 * @file
 * @brief Calculate quadratic equation with complex roots, i.e. b^2 - 4ac < 0.
 * @see https://en.wikipedia.org/wiki/Quadratic_equation,
 * https://en.wikipedia.org/wiki/Quadratic_equation#discriminant
 *
 * @author [Renjian-buchai](https://github.com/Renjian-buchai)
 *
 * @description Calculates any quadratic equation in form ax^2 + bx + c.
 *
 * Quadratic equation:
 * x = (-b +/- sqrt(b^2 - 4ac)) / 2a
 *
 * @example
 * using namespace std;
 * int main() {
 *   array<complex<long double, 2> solutions = quadraticEquation(1, 2, 1);
 *   cout << solutions[0] << " " << solutions[1] << "\n";
 *
 *   solutions = quadraticEquation(1, 1, 1);  // Reusing solutions.
 *   cout << solutions[0] << " " << solutions[1] << "\n";
 *   return 0;
 * }
 *
 * Output:
 * (-1, 0) (-1, 0)
 * (-0.5,0.866025) (-0.5,0.866025)
 */

#include <array>      /// std::array
#include <cassert>    /// assert
#include <cmath>      /// std::sqrt, std::trunc, std::pow
#include <complex>    /// std::complex
#include <exception>  /// std::invalid_argument
#include <iomanip>    /// std::setprecision
#include <iostream>   /// std::cout

/**
 * @brief Quadratic equation calculator.
 * @param a quadratic coefficient.

Review comment (suggestion):
```suggestion
 * using std::array;
 * using std::cout;
```


Code after:
/**
 * @file
 * @brief Calculate quadratic equation with complex roots, i.e. b^2 - 4ac < 0.
 *
 * @author [Renjian-buchai](https://github.com/Renjian-buchai)
 *
 * @description Calculates any quadratic equation in form ax^2 + bx + c.
 *
 * Quadratic equation:
 * x = (-b +/- sqrt(b^2 - 4ac)) / 2a
 *
 * @example
 * int main() {
 *   using std::array;
 *   using std::complex;
 *   using std::cout;
 *
 *   array<complex<long double, 2> solutions = quadraticEquation(1, 2, 1);
 *   cout << solutions[0] << " " << solutions[1] << "\n";
 *
 *   solutions = quadraticEquation(1, 1, 1);  // Reusing solutions.
 *   cout << solutions[0] << " " << solutions[1] << "\n";
 *   return 0;
 * }
 *
 * Output:
 * (-1, 0) (-1, 0)
 * (-0.5,0.866025) (-0.5,0.866025)
 */

#include <array>      /// std::array
#include <cassert>    /// assert
#include <cmath>      /// std::sqrt, std::trunc, std::pow
#include <complex>    /// std::complex
#include <exception>  /// std::invalid_argument
#include <iomanip>    /// std::setprecision
#include <iostream>   /// std::cout

/**
 * @namespace
Repository: TheAlgorithms/C-Plus-Plus
File: math/iterative_factorial.cpp (C++)

Code before:
/**
 * @file
 * @brief Iterative implementation of factorial
 *
 * @author [Renjian-buchai](https://github.com/Renjian-buchai)
 *
 * @description Calculates factorial iteratively.
 *
 * @example
 * int main() {
 *     using std::cout;
 *
 *     cout << "10! = " math::iterativeFactorial(10);
 * }
 *
 * Output:
 * 10! = 3,628,800
 *
 */

#include <cassert>
#include <exception>
#include <iostream>

/**
 * @namespace
 * @brief Mathematical algorithms
 */
namespace math {

/**
 * @brief Calculates the factorial iteratively.
 * @param n Nth factorial.
 * @return Factorial.
 * @note 0! = 1.
 * @warning Maximum=20 because there are no 128-bit integers in C++. 21!
 * returns 1.419e+19, which is not 21! but (21! % UINT64_MAX).
 */
uint64_t iterativeFactorial(uint8_t n) {
    if (n > 20) {
        throw new std::invalid_argument("Maximum n value is 20");
    }

    // 1 because it is the identity number of multiplication.
    uint64_t accumulator = 1;

    while (n > 0) {
        accumulator *= n;

Review comment (suggestion):
```suggestion
#include <cassert> /// for assert
#include <exception> /// for std::invalid_argument
#include <iostream> /// for I/O operations
```

Code after:
/**
 * @file
 * @brief Iterative implementation of
 * [Factorial](https://en.wikipedia.org/wiki/Factorial)
 *
 * @author [Renjian-buchai](https://github.com/Renjian-buchai)
 *
 * @details Calculates factorial iteratively.
 * \f[n! = n\times(n-1)\times(n-2)\times(n-3)\times\ldots\times3\times2\times1
 *       = n\times(n-1)!\f]
 * for example:
 * \f$4! = 4\times3! = 4\times3\times2\times1 = 24\f$
 *
 * @example
 *
 * 5! = 5 * 4 * 3 * 2 * 1
 *
 * Recursive implementation of factorial pseudocode:
 *
 * function factorial(n):
 *     if n == 1:
 *         return 1
 *     else:
 *         return factorial(n-1)
 *
 */

#include <cassert>    /// for assert
#include <cstdint>    /// for integral types
#include <exception>  /// for std::invalid_argument
#include <iostream>   /// for std::cout

/**
 * @namespace
 * @brief Mathematical algorithms
 */
namespace math {

/**
 * @brief Calculates the factorial iteratively.
 * @param n Nth factorial.
 * @return Factorial.
 * @note 0! = 1.
 * @warning Maximum=20 because there are no 128-bit integers in C++. 21!
 * returns 1.419e+19, which is not 21! but (21! % UINT64_MAX).
 */
uint64_t iterativeFactorial(uint8_t n) {
    if (n > 20) {
Repository: TheAlgorithms/C-Plus-Plus
File: math/iterative_factorial.cpp (C++)

Code before:
/**
 * @file
 * @brief Iterative implementation of factorial
 *
 * @author [Renjian-buchai](https://github.com/Renjian-buchai)
 *
 * @description Calculates factorial iteratively.
 *
 * @example
 * int main() {
 *     using std::cout;
 *
 *     cout << "10! = " math::iterativeFactorial(10);
 * }
 *
 * Output:
 * 10! = 3,628,800
 *
 */

#include <cassert>
#include <exception>
#include <iostream>

/**
 * @namespace
 * @brief Mathematical algorithms
 */

Review comment (suggestion):
I think adding a reference to factorials would be nice
i.e: www.wikipedia.com/https://en.wikipedia.org/wiki/Factorial
```suggestion
 * @brief Iterative implementation of [factorial](www.wikipedia.com/https://en.wikipedia.org/wiki/Factorial)
```

Code after:
/**
 * @file
 * @brief Iterative implementation of
 * [Factorial](https://en.wikipedia.org/wiki/Factorial)
 *
 * @author [Renjian-buchai](https://github.com/Renjian-buchai)
 *
 * @details Calculates factorial iteratively.
 * \f[n! = n\times(n-1)\times(n-2)\times(n-3)\times\ldots\times3\times2\times1
 *       = n\times(n-1)!\f]
 * for example:
 * \f$4! = 4\times3! = 4\times3\times2\times1 = 24\f$
 *
 * @example
 *
 * 5! = 5 * 4 * 3 * 2 * 1
 *
 * Recursive implementation of factorial pseudocode:
 *
 * function factorial(n):
 *     if n == 1:
 *         return 1
 *     else:
 *         return factorial(n-1)
 *
 */

#include <cassert>    /// for assert