Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 Coding challenge

views
     
TScodercoder
post May 9 2023, 09:23 AM, updated 3y ago

Getting Started
**
Junior Member
148 posts

Joined: Jan 2023
Try to solve this with any programming language and don't use ChatGPT / google laugh.gif


Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).

If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable numbers.

For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; therefore d(220) = 284.The proper divisors of 284 are 1, 2, 4, 71 and 142; so d(284) = 220.

Evaluate the sum of all the amicable numbers under 10000.
TScodercoder
post May 9 2023, 01:43 PM

Getting Started
**
Junior Member
148 posts

Joined: Jan 2023
QUOTE(jusbella @ May 9 2023, 09:29 AM)
31626
*
Share code la. How long you took to complete it? icon_rolleyes.gif
TScodercoder
post May 9 2023, 05:16 PM

Getting Started
**
Junior Member
148 posts

Joined: Jan 2023
QUOTE(angch @ May 9 2023, 02:55 PM)
CODE
angch@mondas code % cat golf.pl
for(1..1e4){for($i=$_*2;$i<=1e4;$i+=$_){$a[$i]+=$_}}
for(1..1e4){$b=$a[$_];$s+=$_ if$_==$a[$b]&&$_!=$b;}
print$s;                                                                                
angch@mondas code % perl golf.pl
31626%  


Of course I have to golf it. 113 bytes.
*
Pro coder notworthy.gif rclxms.gif

 

Change to:
| Lo-Fi Version
0.0144sec    0.75    6 queries    GZIP Disabled
Time is now: 24th December 2025 - 10:16 AM