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/d5/df6/check__amicable__pair_8cpp_source.html below:

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

Go to the documentation of this file. 32 // Variable to store the sum of all proper divisors. 34 // Below loop condition helps to reduce Time complexity by a factor of 35 // square root of the number. 36 for

(

int

div = 2; div * div <= num; ++div) {

37 // Check 'div' is divisor of 'num'. 39 // If both divisor are same, add once to 'sum' 40 if

(div == (num / div)) {

43 // If both divisor are not the same, add both to 'sum'. 44

sum += (div + (num / div));

74

std::cout <<

"All tests have successfully passed!"

<< std::endl;

82 tests

();

// perform self-tests implementations

static void tests()

Self-test implementations.

int main()

Main function.

bool are_amicable(int x, int y)

Function to check whether the pair is amicable or not.

int sum_of_divisor(int num)

Function to calculate the sum of all the proper divisor of an integer.


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