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

Code before:
/**
 * @file
 * @brief A C++ Program to check whether a pair of numbers is an [amicable
 * pair](https://en.wikipedia.org/wiki/Amicable_numbers) or not.
 *
 * @details
 * An Amicable Pair is two positive integers such that the sum of the proper
 * divisor for each number is equal to the other number.
 *
 * @note Remember that a proper divisor is any positive whole number that
 * divides into a selected number, apart from the selected number itself, and
 * returns a positive integer. for example 1, 2 and  5 are all proper divisors
 * of 10.
 *
 * @author [iamnambiar](https://github.com/iamnambiar)
 */
#include <cassert>   // for assert
#include <iostream>  // for cout

/**
 * @brief Mathematical algorithms
 * @namespace
 */
namespace math {
/**
 * @brief Function to calculate the sum of all the proper divisor
 * of an integer.
 * @param num selected number.
 * @return Sum of the proper divisor of the number.
 */
int sum_of_divisor(int num) {
    // Variable to store the sum of all proper divisors.
    int sum = 1;
    // Below loop condition helps to reduce Time complexity by a factor of
    // square root of the number.
    for (int div = 2; div * div <= num; ++div) {
        // Check 'div' is divisor of 'num'.
        if (num % div == 0) {
            // If both divisor are same, add once to 'sum'
            if (div == (num / div)) {
                sum += div;
            } else {
                // If both divisor are not the same, add both to 'sum'.

Review comment (suggestion):
```suggestion
#include <cassert>   /// for assert
#include <iostream>  /// for cout
```

Code after:
/**
 * @file
 * @brief A C++ Program to check whether a pair of numbers is an [amicable
 * pair](https://en.wikipedia.org/wiki/Amicable_numbers) or not.
 *
 * @details
 * An Amicable Pair is two positive integers such that the sum of the proper
 * divisor for each number is equal to the other number.
 *
 * @note Remember that a proper divisor is any positive whole number that
 * divides into a selected number, apart from the selected number itself, and
 * returns a positive integer. for example 1, 2 and  5 are all proper divisors
 * of 10.
 *
 * @author [iamnambiar](https://github.com/iamnambiar)
 */
#include <cassert>   /// for assert
#include <iostream>  /// for IO operations

/**
 * @brief Mathematical algorithms
 * @namespace
 */
namespace math {
/**
 * @brief Function to calculate the sum of all the proper divisor
 * of an integer.
 * @param num selected number.
 * @return Sum of the proper divisor of the number.
 */
int sum_of_divisor(int num) {
    // Variable to store the sum of all proper divisors.
    int sum = 1;
    // Below loop condition helps to reduce Time complexity by a factor of
    // square root of the number.
    for (int div = 2; div * div <= num; ++div) {
        // Check 'div' is divisor of 'num'.
        if (num % div == 0) {
            // If both divisor are same, add once to 'sum'
            if (div == (num / div)) {
                sum += div;
            } else {
                // If both divisor are not the same, add both to 'sum'.
Repository: TheAlgorithms/C-Plus-Plus
File: math/check_amicable_pair.cpp (C++)

Code before:
}

/**
 * @brief Function to check whether the pair is amicable or not.
 * @param x First number.
 * @param y Second number.
 * @return `true` if the pair is amicable
 * @return `false` if the pair is not amicable
 */
bool are_amicable(int x, int y) {
    return (sum_of_divisor(x) == y) && (sum_of_divisor(y) == x);
}
}  // namespace math

/**
 * @brief Self-test implementations
 * @returns void
 */
void tests() {
    assert(math::are_amicable(220, 284) == true);
    assert(math::are_amicable(6368, 6232) == true);
    assert(math::are_amicable(458, 232) == false);
    assert(math::are_amicable(17296, 18416) == true);
    assert(math::are_amicable(18416, 17296) == true);

    std::cout << "all tests have passed" << std::endl;
}

/**
 * @brief Main function
 * @returns 0 on exit
 */
int main() {
    tests();  // perform self-tests implementations
    return 0;
}


Review comment (suggestion):
```suggestion
    std::cout << "All tests have successfully passed!" << std::endl;
```


Code after:
}

/**
 * @brief Function to check whether the pair is amicable or not.
 * @param x First number.
 * @param y Second number.
 * @return `true` if the pair is amicable
 * @return `false` if the pair is not amicable
 */
bool are_amicable(int x, int y) {
    return (sum_of_divisor(x) == y) && (sum_of_divisor(y) == x);
}
}  // namespace math

/**
 * @brief Self-test implementations
 * @returns void
 */
static void tests() {
    assert(math::are_amicable(220, 284) == true);
    assert(math::are_amicable(6368, 6232) == true);
    assert(math::are_amicable(458, 232) == false);
    assert(math::are_amicable(17296, 18416) == true);
    assert(math::are_amicable(18416, 17296) == true);

    std::cout << "All tests have successfully passed!" << std::endl;
}

/**
 * @brief Main function
 * @returns 0 on exit
 */
int main() {
    tests();  // perform self-tests implementations
    return 0;
}
Repository: TheAlgorithms/C-Plus-Plus
File: math/check_amicable_pair.cpp (C++)

Code before:
/**
 * @file
 * @brief A C++ Program to check whether a pair of numbers is an [amicable
 * pair](https://en.wikipedia.org/wiki/Amicable_numbers) or not.
 *
 * @details
 * An Amicable Pair is two positive integers such that the sum of the proper
 * divisor for each number is equal to the other number.
 *
 * @note Remember that a proper divisor is any positive whole number that
 * divides into a selected number, apart from the selected number itself, and
 * returns a positive integer. for example 1, 2 and  5 are all proper divisors
 * of 10.
 *
 * @author [iamnambiar](https://github.com/iamnambiar)
 */
#include <cassert>   /// for assert
#include <iostream>  /// for cout

/**
 * @brief Mathematical algorithms
 * @namespace
 */
namespace math {
/**
 * @brief Function to calculate the sum of all the proper divisor
 * of an integer.
 * @param num selected number.
 * @return Sum of the proper divisor of the number.
 */
int sum_of_divisor(int num) {
    // Variable to store the sum of all proper divisors.
    int sum = 1;
    // Below loop condition helps to reduce Time complexity by a factor of
    // square root of the number.
    for (int div = 2; div * div <= num; ++div) {
        // Check 'div' is divisor of 'num'.
        if (num % div == 0) {
            // If both divisor are same, add once to 'sum'
            if (div == (num / div)) {
                sum += div;
            } else {
                // If both divisor are not the same, add both to 'sum'.

Review comment (suggestion):
```suggestion
#include <iostream>  /// for IO operations
```


Code after:
/**
 * @file
 * @brief A C++ Program to check whether a pair of numbers is an [amicable
 * pair](https://en.wikipedia.org/wiki/Amicable_numbers) or not.
 *
 * @details
 * An Amicable Pair is two positive integers such that the sum of the proper
 * divisor for each number is equal to the other number.
 *
 * @note Remember that a proper divisor is any positive whole number that
 * divides into a selected number, apart from the selected number itself, and
 * returns a positive integer. for example 1, 2 and  5 are all proper divisors
 * of 10.
 *
 * @author [iamnambiar](https://github.com/iamnambiar)
 */
#include <cassert>   /// for assert
#include <iostream>  /// for IO operations

/**
 * @brief Mathematical algorithms
 * @namespace
 */
namespace math {
/**
 * @brief Function to calculate the sum of all the proper divisor
 * of an integer.
 * @param num selected number.
 * @return Sum of the proper divisor of the number.
 */
int sum_of_divisor(int num) {
    // Variable to store the sum of all proper divisors.
    int sum = 1;
    // Below loop condition helps to reduce Time complexity by a factor of
    // square root of the number.
    for (int div = 2; div * div <= num; ++div) {
        // Check 'div' is divisor of 'num'.
        if (num % div == 0) {
            // If both divisor are same, add once to 'sum'
            if (div == (num / div)) {
                sum += div;
            } else {
                // If both divisor are not the same, add both to 'sum'.
Repository: TheAlgorithms/C-Plus-Plus
File: math/check_factorial.cpp (C++)

Code before:
/**
 * @file
 * @brief A simple program to check if the given number is a factorial of some
 * number or not. https://en.wikipedia.org/wiki/Factorial
 *
 * @details 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](https://github.com/divyajyotiuk)
 */
#include <cassert>   // for assert
#include <iostream>  // for cout

namespace math {
/**
 * @brief Function to check if the given number is factorial of some number or
 * not.
 * @param n number to be checked.
 * @return true if number is a factorial returns true
 * @return false if number is not a factorial
 */
bool is_factorial(uint64_t n) {
    if (n <= 0) {  // factorial numbers are only ever positive Integers
        return false;
    }

    /*!
     * this loop is basically a reverse factorial calculation, where instead
     * of multiplying we are dividing. We start at i = 2 since i = 1 has
     * no impact division wise
     */
    int i = 2;
    while (n % i == 0) {
        n = n / i;
        i++;
    }


Review comment (suggestion):
```suggestion
#include <cassert>   /// for assert
#include <iostream>  /// for cout
```

Code after:
/**
 * @file
 * @brief A simple program to check if the given number is a [factorial](https://en.wikipedia.org/wiki/Factorial) of some
 * number or not.
 *
 * @details 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](https://github.com/divyajyotiuk)
 * @author [ewd00010](https://github.com/ewd00010)
 */
#include <cassert>   /// for assert
#include <iostream>  /// for cout

/**
 * @namespace
 * @brief Mathematical algorithms
 */
namespace math {
/**
 * @brief Function to check if the given number is factorial of some number or
 * not.
 * @param n number to be checked.
 * @return true if number is a factorial returns true
 * @return false if number is not a factorial
 */
bool is_factorial(uint64_t n) {
    if (n <= 0) {  // factorial numbers are only ever positive Integers
        return false;
    }

    /*!
     * this loop is basically a reverse factorial calculation, where instead
     * of multiplying we are dividing. We start at i = 2 since i = 1 has
     * no impact division wise
     */
    int i = 2;
Repository: TheAlgorithms/C-Plus-Plus
File: math/check_factorial.cpp (C++)

Code before:
/**
 * @file
 * @brief A simple program to check if the given number is a factorial of some
 * number or not. https://en.wikipedia.org/wiki/Factorial
 *
 * @details 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](https://github.com/divyajyotiuk)
 */
#include <cassert>   // for assert
#include <iostream>  // for cout

namespace math {
/**
 * @brief Function to check if the given number is factorial of some number or
 * not.
 * @param n number to be checked.
 * @return true if number is a factorial returns true
 * @return false if number is not a factorial
 */
bool is_factorial(uint64_t n) {
    if (n <= 0) {  // factorial numbers are only ever positive Integers
        return false;
    }

    /*!
     * this loop is basically a reverse factorial calculation, where instead

Review comment (suggestion):
```suggestion
 * @brief A simple program to check if the given number is a [factorial](https://en.wikipedia.org/wiki/Factorial) of some
```
hyperlinks seem more neat in this case

Code after:
/**
 * @file
 * @brief A simple program to check if the given number is a [factorial](https://en.wikipedia.org/wiki/Factorial) of some
 * number or not.
 *
 * @details 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](https://github.com/divyajyotiuk)
 * @author [ewd00010](https://github.com/ewd00010)
 */
#include <cassert>   /// for assert
#include <iostream>  /// for cout

/**
 * @namespace
 * @brief Mathematical algorithms
 */
namespace math {
/**
 * @brief Function to check if the given number is factorial of some number or
 * not.
 * @param n number to be checked.
 * @return true if number is a factorial returns true
 * @return false if number is not a factorial
 */
bool is_factorial(uint64_t n) {
    if (n <= 0) {  // factorial numbers are only ever positive Integers
Repository: TheAlgorithms/C-Plus-Plus
File: math/check_factorial.cpp (C++)

Code before:
/**
 * @file
 * @brief A simple program to check if the given number is a [factorial](https://en.wikipedia.org/wiki/Factorial) of some
 * number or not.
 *
 * @details 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](https://github.com/divyajyotiuk)
 */
#include <cassert>   /// for assert
#include <iostream>  /// for cout

namespace math {
/**
 * @brief Function to check if the given number is factorial of some number or
 * not.
 * @param n number to be checked.
 * @return true if number is a factorial returns true
 * @return false if number is not a factorial
 */
bool is_factorial(uint64_t n) {
    if (n <= 0) {  // factorial numbers are only ever positive Integers
        return false;
    }

    /*!
     * this loop is basically a reverse factorial calculation, where instead
     * of multiplying we are dividing. We start at i = 2 since i = 1 has
     * no impact division wise
     */
    int i = 2;
    while (n % i == 0) {
        n = n / i;
        i++;
    }

    /*!
     * if n was the sum of a factorial then it should be divided until it
     * becomes 1
     */
    if (n == 1) {
        return true;
    } else {

Review comment (suggestion):
Missing namespace Doxygen documentation.
```suggestion
/**
 * @namespace
 * @brief Mathematical algorithms
 */
namespace math {
```


Code after:
/**
 * @file
 * @brief A simple program to check if the given number is a [factorial](https://en.wikipedia.org/wiki/Factorial) of some
 * number or not.
 *
 * @details 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](https://github.com/divyajyotiuk)
 * @author [ewd00010](https://github.com/ewd00010)
 */
#include <cassert>   /// for assert
#include <iostream>  /// for cout

/**
 * @namespace
 * @brief Mathematical algorithms
 */
namespace math {
/**
 * @brief Function to check if the given number is factorial of some number or
 * not.
 * @param n number to be checked.
 * @return true if number is a factorial returns true
 * @return false if number is not a factorial
 */
bool is_factorial(uint64_t n) {
    if (n <= 0) {  // factorial numbers are only ever positive Integers
        return false;
    }

    /*!
     * this loop is basically a reverse factorial calculation, where instead
     * of multiplying we are dividing. We start at i = 2 since i = 1 has
     * no impact division wise
     */
    int i = 2;
    while (n % i == 0) {
        n = n / i;
        i++;
    }

    /*!
     * if n was the sum of a factorial then it should be divided until it
Repository: TheAlgorithms/C-Plus-Plus
File: math/check_factorial.cpp (C++)

Code before:

    /*!
     * if n was the sum of a factorial then it should be divided until it
     * becomes 1
     */
    if (n == 1) {
        return true;
    } else {
        return false;
    }
}
}  // namespace math

/**
 * @brief Test function
 * @returns void
 */
void tests() {
    assert(math::is_factorial(50) == false);
    assert(math::is_factorial(720) == true);
    assert(math::is_factorial(0) == false);
    assert(math::is_factorial(1) == true);
    assert(math::is_factorial(479001600) == true);
    assert(math::is_factorial(-24) == false);

    std::cout << "all tests have passed successfully" << std::endl;
}

/**
 * @brief Main function
 * @returns 0 on exit
 */
int main() {
    tests();  // runs self-test implementation
    return 0;
}


Review comment (suggestion):
```suggestion
    std::cout << "All tests have successfully passed!" << std::endl;
```


Code after:
    int i = 2;
    while (n % i == 0) {
        n = n / i;
        i++;
    }

    /*!
     * if n was the sum of a factorial then it should be divided until it
     * becomes 1
     */
    return (n == 1);
}
}  // namespace math

/**
 * @brief Self-test implementations
 * @returns void
 */
static void tests() {
    assert(math::is_factorial(50) == false);
    assert(math::is_factorial(720) == true);
    assert(math::is_factorial(0) == false);
    assert(math::is_factorial(1) == true);
    assert(math::is_factorial(479001600) == true);
    assert(math::is_factorial(-24) == false);

    std::cout << "All tests have successfully passed!" << std::endl;
}

/**
 * @brief Main function
 * @returns 0 on exit
 */
int main() {
    tests();  // run self-test implementations
    return 0;
}
Repository: TheAlgorithms/C-Plus-Plus
File: math/check_factorial.cpp (C++)

Code before:

    /*!
     * this loop is basically a reverse factorial calculation, where instead
     * of multiplying we are dividing. We start at i = 2 since i = 1 has
     * no impact division wise
     */
    int i = 2;
    while (n % i == 0) {
        n = n / i;
        i++;
    }

    /*!
     * if n was the sum of a factorial then it should be divided until it
     * becomes 1
     */
    if (n == 1) {
        return true;
    } else {
        return false;
    }
}
}  // namespace math

/**
 * @brief Test function
 * @returns void
 */
void tests() {
    assert(math::is_factorial(50) == false);
    assert(math::is_factorial(720) == true);
    assert(math::is_factorial(0) == false);
    assert(math::is_factorial(1) == true);
    assert(math::is_factorial(479001600) == true);
    assert(math::is_factorial(-24) == false);

    std::cout << "all tests have passed successfully" << std::endl;
}

/**
 * @brief Main function
 * @returns 0 on exit
 */
int main() {
    tests();  // runs self-test implementation
    return 0;
}


Review comment (suggestion):
```suggestion
 * @brief Self-test implementations
```


Code after:
 */
bool is_factorial(uint64_t n) {
    if (n <= 0) {  // factorial numbers are only ever positive Integers
        return false;
    }

    /*!
     * this loop is basically a reverse factorial calculation, where instead
     * of multiplying we are dividing. We start at i = 2 since i = 1 has
     * no impact division wise
     */
    int i = 2;
    while (n % i == 0) {
        n = n / i;
        i++;
    }

    /*!
     * if n was the sum of a factorial then it should be divided until it
     * becomes 1
     */
    return (n == 1);
}
}  // namespace math

/**
 * @brief Self-test implementations
 * @returns void
 */
static void tests() {
    assert(math::is_factorial(50) == false);
    assert(math::is_factorial(720) == true);
    assert(math::is_factorial(0) == false);
    assert(math::is_factorial(1) == true);
    assert(math::is_factorial(479001600) == true);
    assert(math::is_factorial(-24) == false);

    std::cout << "All tests have successfully passed!" << std::endl;
}

/**
 * @brief Main function
 * @returns 0 on exit
 */
int main() {
    tests();  // run self-test implementations
    return 0;
}
Repository: TheAlgorithms/C-Plus-Plus
File: math/check_factorial.cpp (C++)

Code before:
        return false;
    }
}
}  // namespace math

/**
 * @brief Test function
 * @returns void
 */
void tests() {
    assert(math::is_factorial(50) == false);
    assert(math::is_factorial(720) == true);
    assert(math::is_factorial(0) == false);
    assert(math::is_factorial(1) == true);
    assert(math::is_factorial(479001600) == true);
    assert(math::is_factorial(-24) == false);

    std::cout << "all tests have passed successfully" << std::endl;
}

/**
 * @brief Main function
 * @returns 0 on exit
 */
int main() {
    tests();  // runs self-test implementation
    return 0;
}


Review comment (suggestion):
```suggestion
    tests();  // run self-test implementations
```


Code after:
     * becomes 1
     */
    return (n == 1);
}
}  // namespace math

/**
 * @brief Self-test implementations
 * @returns void
 */
static void tests() {
    assert(math::is_factorial(50) == false);
    assert(math::is_factorial(720) == true);
    assert(math::is_factorial(0) == false);
    assert(math::is_factorial(1) == true);
    assert(math::is_factorial(479001600) == true);
    assert(math::is_factorial(-24) == false);

    std::cout << "All tests have successfully passed!" << std::endl;
}

/**
 * @brief Main function
 * @returns 0 on exit
 */
int main() {
    tests();  // run self-test implementations
    return 0;
}
Repository: TheAlgorithms/C-Plus-Plus
File: math/check_factorial.cpp (C++)

Code before:
/**
 * @file
 * @brief A simple program to check if the given number is a [factorial](https://en.wikipedia.org/wiki/Factorial) of some
 * number or not.
 *
 * @details 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](https://github.com/divyajyotiuk)
 */
#include <cassert>   /// for assert
#include <iostream>  /// for cout

/**
 * @namespace
 * @brief Mathematical algorithms
 */
namespace math {
/**
 * @brief Function to check if the given number is factorial of some number or
 * not.
 * @param n number to be checked.
 * @return true if number is a factorial returns true
 * @return false if number is not a factorial
 */
bool is_factorial(uint64_t n) {
    if (n <= 0) {  // factorial numbers are only ever positive Integers
        return false;
    }

    /*!
     * this loop is basically a reverse factorial calculation, where instead
     * of multiplying we are dividing. We start at i = 2 since i = 1 has
     * no impact division wise

Review comment (security):
```suggestion
 * @author [Divyajyoti Ukirde](https://github.com/divyajyotiuk)
 * @author [ewd00010](https://github.com/ewd00010)
```


Code after:
/**
 * @file
 * @brief A simple program to check if the given number is a [factorial](https://en.wikipedia.org/wiki/Factorial) of some
 * number or not.
 *
 * @details 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](https://github.com/divyajyotiuk)
 * @author [ewd00010](https://github.com/ewd00010)
 */
#include <cassert>   /// for assert
#include <iostream>  /// for cout

/**
 * @namespace
 * @brief Mathematical algorithms
 */
namespace math {
/**
 * @brief Function to check if the given number is factorial of some number or
 * not.
 * @param n number to be checked.
 * @return true if number is a factorial returns true
 * @return false if number is not a factorial
 */
bool is_factorial(uint64_t n) {
    if (n <= 0) {  // factorial numbers are only ever positive Integers
        return false;
    }

    /*!
     * this loop is basically a reverse factorial calculation, where instead
     * of multiplying we are dividing. We start at i = 2 since i = 1 has