Problem 45424. Amicable pair
Amicable numbers are two different numbers such that the sum of the proper divisors of each is equal to the other number.
For example,
220 = 1, 2, 4, 5, 10, 11, 20, 22, 44, 55, 110 ; sum =284
284 = 1, 2, 4, 71, 142 ; sum =220
So, 220 & 284 make an amicable pair.
Find the number of such pairs within n.
Update - Test cases added at 09-09-22
Solution Stats
Problem Comments
-
3 Comments
Rafael S.T. Vieira
on 6 Sep 2020
The 8th test case is correct and can be solved within Cody's time limit. Why is it not being used? Up to 200.000, there are 20 amicable pairs.
Rafael S.T. Vieira
on 6 Sep 2020
For instance 176272,180848 is the 20th pair. For 3e5 my code can't go fast enough for Cody (45s), but I've found just 2 additional pairs 196724, 202444 and 185368, 203432.
Dyuman Joshi
on 9 Sep 2022
Test cases added (upper limit changed from 5e4 to 7.5e4).
More test cases might be added later (upper limit 9e4)
Note - Some solutions have failed to run in cody time limit for test case 7.5e4, and some more will fail for 9e4.
Solution Comments
Show commentsProblem Recent Solvers6
Suggested Problems
-
3662 Solvers
-
1558 Solvers
-
Determine the number of odd integers in a vector
731 Solvers
-
104 Solvers
-
226 Solvers
More from this Author165
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!