Find first 10 pairs of amicable numbers I took it as a challenge to write a C++ program to find the first 10 amicable-number pairs.
Amicable numbers
Let's take 4. What are the proper divisors of 4?. They are 1 and 2. Their sum is 3.
Now let's do the same thing for the number 220. The sum of the proper divisors of 220 is 284.
The sum of proper divisors of the number 284 is 220.
If the sum of proper divisors of two numbers are equal to each other then they are amicable.
For example 284 and 220, whose proper factors sum to 220 and 284 respectively, are amicable.
This is my C++ program to find the first 10 amicable numbers.
#include&lt;iostream&gt;

int GetSumOfFactors(int num){
    int sum = 0;
    for(int i = 1;i &lt; num/2+1;i++){
        if(num % i==0){
            sum+=i;
        }
    }
    return sum;
}
int main(){
    int sum_of_factors = 0;
    int counter = 0;
    int num = 0;
    for(;;){
        num++;
        sum_of_factors = GetSumOfFactors(num);
        if(num == sum_of_factors) continue;
        if (GetSumOfFactors(sum_of_factors) == num &amp;&amp; num &gt; sum_of_factors){
            std::cout &lt;&lt; &quot;Pair: &quot; &lt;&lt; num &lt;&lt; &quot; &quot; &lt;&lt; sum_of_factors &lt;&lt; &quot;\n&quot;;
            counter+=1;
        }
        if(counter == 10) break;
    }
    return 1;
}


To make sure I don't find the same pair twice, that means 220 to 284, just like 284 to 220, I keep an extra condition where the number should be greater than its sum of factors.
Output:
Pair: 284 220
Pair: 1210 1184
Pair: 2924 2620
Pair: 5564 5020
Pair: 6368 6232
Pair: 10856 10744
Pair: 14595 12285
Pair: 18416 17296
Pair: 66992 66928
Pair: 71145 67095

Process returned 1 (0x1)   execution time : 4.955 s
Press any key to continue.
I'll add some remarks (adding to what Miguel Avila already said) and then focus on the performance aspect.

Use consistent naming: you mix camel case (FactorsSum) and snake case (sum_of_factors).
Use consistent spacing (after keywords like if and around operators).
Declare variables and the narrowest possible scope. As an example, sum_of_factors is only needed inside the for-loop.
Use proper exit codes. A non-zero exit code indicates the failure of a program. You'll want to return 0; or return EXIT_SUCCESS;. In fact you can simply omit the return statement: Reaching the end of main() does an implicit return 0; in C++.

If you care about portability: C++ does not specify the size of int, only its minimum range (which is -32767 to 32767). You should use long (with a minimum range -2147483647 to 2147483647) or one of the fixed-size types (int32_t or int64_t) depending on the needed range.
Performance improvement #1
Computing the sum of all (proper) divisors of a number can be significantly improved by observing that if \$ i \$ divides \$ n \$ then both \$ i \$ and \$ n/i \$ are divisors of \$ n\$. Therefore it suffices to test all \$ i \le \sqrt n\$. See for example Sum of all proper divisors of a natural number. A possible implementation is
// Returns the sum of all proper divisors of `n`.
int divisor_sum(int n) {
    if (n &lt;= 1) {
        return 0;
    }
    
    int count = 1; // 1 is always a divisor.
    int sqrt_n = (int)sqrt(n); // Upper bound for the loop.
    for (int i = 2; i &lt;= sqrt_n; i++) {
        if (n % i == 0) {
            // `i` and `n / i` are divisors of `n`.
            count += i;
            if (i !=  n / i) {
                count += n / i;
            }
        }
    }
    return count;
}

Performance improvement #2
In your main loop, you compute the divisor sum of sum_of_factors even if that is larger than num:
if (GetSumOfFactors(sum_of_factors) == num &amp;&amp; num &gt; sum_of_factors)

A simple improvement would be to change the order of the expressions:
if (num &gt; sum_of_factors &amp;&amp; GetSumOfFactors(sum_of_factors) == num)

Another option is to remember the divisor sums of numbers which are possible candidates of  an amicable pair, so that they need not be computed again. This can for example be done with a
std::unordered_map&lt;int, int&gt; abundant_divsums;

which holds all abundant numbers with their divisor sums encountered so far. A number is abundant if its proper divisor sum is larger than the number. These are candidates for an amicable pair with higher numbers.
A possible implementation is
#include &lt;unordered_map&gt;

int main()
{
    std::unordered_map&lt;int, int&gt; abundant_divsums;
    
    int num = 1;
    for (int counter = 0; counter &lt; 10; num++) {
        int divsum = divisor_sum(num);
        if (divsum &gt; num) {
            abundant_divsums[num] = divsum;
        } else if (divsum &lt; num) {
            if (abundant_divsums.find(divsum) != abundant_divsums.end() &amp;&amp; abundant_divsums[divsum] == num) {
                std::cout &lt;&lt; &quot;Pair: &quot; &lt;&lt; num &lt;&lt; ' ' &lt;&lt; divsum &lt;&lt; '\n';
                counter++;
            }
        }
    }
}

Benchmarks
The tests were done on a MacBook Air (1.1 GHz Quad-Core Intel Core i5), with the code compiled with optimizations (“Release” configuration).
I measured the time for computing the first 10/20/50 amicable pairs. All times are in seconds.




# of amicable pairs
10
20
50




Original code:
3.8
24



After improvement #1:
0.08
0.2
3.8


After improvement #2:
0.05
0.15
2.5