[Question]
  [
A [*proper divisor*](http://mathworld.wolfram.com/ProperDivisor.html) is a [divisor](https://en.wikipedia.org/wiki/Divisor) of a number *n*, which is not *n* itself. For example, the proper divisors of 12 are 1, 2, 3, 4 and 6.
You will be given **an integer** *x*, *x* ≥ 2, *x ≤ 1000*. Your task is to sum all the ***highest* proper divisors** of the integers from *2* to *x* (inclusive) (OEIS [A280050](http://oeis.org/A280050)).
### Example (with `x = 6`):
* Find all the integers between 2 and 6 (inclusive): 2,3,4,5,6.
* Get the proper divisors of all of them, and pick the highest ones from each number:
	+ 2 -> **1**
	+ 3 -> **1**
	+ 4 -> 1, **2**
	+ 5 -> **1**
	+ 6 -> 1, 2, **3**.
* Sum the highest proper divisors: `1 + 1 + 2 + 1 + 3 = 8`.
* The final result is 8.
# Test Cases
```
Input  |  Output
-------+---------
       |
 2     | 1
 4     | 4
 6     | 8
 8     | 13
 15    | 41
 37    | 229
 100   | 1690
 1000  | 165279
```
# Rules
* [Default Loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) apply.
* You can take input and provide output by [any standard method](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods).
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), the shortest valid submission in each language wins! Have Fun!
  
[Answer]
# [Oasis](https://github.com/Adriandmen/Oasis), 4 bytes
### Code:
```
nj+U
```
[Try it online!](https://tio.run/##y08sziz@/z8vSzv0////FgA "Oasis – Try It Online")
### Explanation:
Extended version:
```
nj+00
    0   = a(0)
   0    = a(1)
a(n) =
n       # Push n
 j      # Get the largest divisor under n
  +     # Add to a(n - 1)
```
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 10 bytes
```
⟦bb{fkt}ᵐ+
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r//9H8ZUlJ1WnZJbUPt07Q/v/f0MDA4H8UAA "Brachylog – Try It Online")
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), ~~13~~ ~~9~~ 8 bytes
1 byte thanks to jacoblaw.
```
tsm*FtPh
```
[Test suite](http://pyth.herokuapp.com/?code=tsm%2aFtPh&test_suite=1&test_suite_input=2%0A4%0A6%0A8%0A15%0A37%0A100%0A1000&debug=0).
## How it works
The largest proper divisor is the product of the prime factors except the smallest one.
[Answer]
## [Husk](https://github.com/barbuz/Husk), 7 bytes
```
ṁȯΠtptḣ
```
[Try it online!](https://tio.run/##yygtzv7//@HOxhPrzy0oKSh5uGPx////jc0B "Husk – Try It Online")
## Explanation
Husk has no built-in for computing the divisors directly (yet), so I'm using prime factorization instead.
The largest proper divisor of a number is the product of its prime factors except the smallest one.
I map this function over the range from 2 to the input, and sum the results.
```
ṁȯΠtptḣ  Define a function:
      ḣ  Range from 1 to input.
     t   Remove the first element (range from 2).
ṁ        Map over the list and take sum:
 ȯ        The composition of
    p     prime factorization,
   t      tail (remove smallest prime) and
  Π       product.
```
[Answer]
# [Python 2](https://docs.python.org/2/), 50 bytes
```
f=lambda n,k=2:n/k and(f(n,k+1),n/k+f(n-1))[n%k<1]
```
This is *slow* and can't even cope with input **15** on TIO.
[Try it online!](https://tio.run/##DYxBCoMwFETX9RSzCSYY2yZIKVJ7kdKFrUqD@iNJXHj69A/M4j2Y2Y7082SzWzcfEuIRC@45jimM3z1E52lxq0vSXDkqT93Sr5@hB@m5sy1dZvQ0yEkyV0ZpFhVDbZR6kZgf5p0nH0BwBKvRaNw07m1x2oKjJEthdtRPCLuXEOAX8Foplf8 "Python 2 – Try It Online")
However, memoization (*thanks @musicman523*) can be used to verify all test cases.
[Try it online!](https://tio.run/##VU5Ra8IwGHw2v@Jeis2MrK3ODamDMRiUbT5svgwRcTbBUJuUNH1wY7@9pikie8mXu/vu7qtO9qBV0gqjSxhe68bsOWRZaWNxQzxdn@orQ2puzVGW0oYfb9l7ttp@rp6eXxk83GbLl2yZrb4Y/kFKvY/vG1NLrXp/jDTFJKKtWBx35Xe@g2LFIpmr2wI7lYcidHgUU@aIkQPjmNK1Coo03rQ5Fyh5qeUPDwWdk0EHsMDvHxl02oEfK25cAArHJt3GQAp4gkJpC6l8QCd487rXNm5d9F@nGG4b0y9edHIh@wpChHNcT3FYG6guPmGYMswYHhjiO4bJvZtR5J/I9VZGKhsOg2mD8SOCWTNE4C90/ZTS9gw "Python 2 – Try It Online")
### Alternate version, 52 bytes
At the cost of 2 bytes, we can choose whether to compute `f(n,k+1)` or `n/k+f(n-1)`.
```
f=lambda n,k=2:n>1and(n%k and f(n,k+1)or n/k+f(n-1))
```
With some trickery, this works for all test cases, even on TIO.
[Try it online!](https://tio.run/##VYxNi8IwGITP9lfMpdhoxMb6haggCwth1YP24kmqthhq35QkPfjr3dg9LF5meB6YqZ/uril5FUZXMLnVjbnmUFWtjUMvaLV92n8T2NyZh6qUiw5buZPp@Zhuvn44WjzL/bfcy/TE8YGMtbv82hirNP3tBZZLJDF7FatHVl1uGYiXq9GC1iKjW0RhCd8oIq/7gmkDGpZ9jwPB/OjNUIQRx5hjyjHnEBOOZOY7jtuIF0GnNopc1A3HDQZrhNOmixD@833M/NEv "Python 3 – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 6 bytes
```
ÆḌ€Ṫ€S
```
[Try it online!](https://tio.run/##y0rNyan8//9w28MdPY@a1jzcuQpIBv///9/QwMAAAA "Jelly – Try It Online")
## How it works
```
ÆḌ€Ṫ€S
ÆḌ€    map proper divisor (1 would become empty array)
           implicitly turns argument into 1-indexed range
   Ṫ€  map last element
     S sum
```
[Answer]
## JavaScript (ES6), 40 bytes
```
f=(n,i=2)=>n<2?0:n%i?f(n,i+1):n/i+f(n-1)
```
```
<input type=number oninput=o.textContent=f(this.value)><pre id=o>
```
A number equals the product of its highest proper divisor and its smallest prime factor.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~9~~ 8 bytes
-1 Byte thanks to [Leaky Nun](https://codegolf.stackexchange.com/users/48934/leaky-nun)'s prime factor trick in his Pyth answer
```
L¦vyÒ¦PO
```
[Try it online!](https://tio.run/##MzBNTDJM/f/f59CyssrDkw4tC/D//9/QwMAAAA "05AB1E – Try It Online")
### Explanation
```
L¦vyÒ¦PO
L¦       # Range [2 .. input]
  vy     # For each...
    Ò¦    # All prime factors except the first one
      P   # Product
       O  # Sum with previous results
         # Implicit print
```
Alternative 8 Byte solution (That doesnt work on TIO)
```
L¦vyÑ¨θO    
```
and ofc alternative 9 Byte solution (That works on TIO)
```
L¦vyÑ¨®èO    
```
[Answer]
# [Retina](https://github.com/m-ender/retina), ~~31~~ 24 bytes
7 bytes thanks to Martin Ender.
```
.+
$*
M!&`(1+)(?=\1+$)
1
```
[Try it online!](https://tio.run/##K0otycxL/P9fT5tLRYvLV1EtQcNQW1PD3jbGUFtFk8vw/39DAwMDAA "Retina – Try It Online")
## How it works
The regex `/^(1+)\1+$/` captures the largest proper divisor of a certain number represented in unary. In the code, the `\1+` is turned to a lookahead syntax.
[Answer]
# Mathematica, 30 bytes
```
Divisors[i][[-2]]~Sum~{i,2,#}&
```
[Answer]
# [Python 2 (PyPy)](http://pypy.org/), ~~73~~ ~~71~~ 70 bytes
```
n=input();r=[0]*n;d=1
while n:n-=1;r[d+d::d]=n/d*[d];d+=1
print sum(r)
```
Not the shortest Python answer, but this just breezes through the test cases. TIO handles inputs up to **30,000,000** without breaking a sweat; my desktop computer handles **300,000,000** in a minute.
At the cost of **2 bytes**, the condition `n>d` could be used for a ~10% speed-up.
*Thanks to @xnor for the `r=[0]*n` idea, which saved 3 bytes!*
[Try it online!](https://tio.run/##JcpBCoAgEADAe6/wqEWkdVP2JeJtA4XaFlPC11vQnIdbiRetMzduvRMk4lqkchm8DiM5BDM8MR27IEszGJc9TmgtBqAFR4/B4fQdzomKuOsps@p9078X "Python 2 (PyPy) – Try It Online")
[Answer]
## Haskell, ~~48~~ ~~46~~ 43 bytes
```
f 2=1
f n=until((<1).mod n)pred(n-1)+f(n-1)
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P03ByNaQK00hz7Y0ryQzR0PDxlBTLzc/RSFPs6AoNUUjT9dQUzsNTP3PTczMU7BVKCjKzCtRUFHITSxQSFOINtIx0THTsdAxNNUxNtcxNDAAYYPY/wA "Haskell – Try It Online")
Edit: @rogaos saved two bytes. Thanks!
Edit II: ... and @xnor another 3 bytes. 
[Answer]
# [Japt](https://github.com/ETHproductions/japt), ~~8+2=10~~ ~~8~~ 6 bytes
```
òâ1 xo
```
[Test it](https://ethproductions.github.io/japt/?v=1.4.5&code=8uIxIHhv&input=MTAw)
* 1 byte saved thanks to ETHproductions.
---
## Explanation
```
    :Implicit input of integer U.
ò   :Generate an array of integers from 1 to U, inclusive
â   :Get the divisors of each number,
1   :  excluding itself.
x   :Sum the main array
o   :by popping the last element from each sub-array.
    :Implicit output of result
```
[Answer]
# MATL, 12 bytes
```
q:Q"@Z\l_)vs
```
Try it at [MATL Online](https://matl.io/?code=q%3AQ%22%40Z%5Cl_%29vs&inputs=37&version=20.1.1)
**Explanation**
```
        % Implicitly grab input (N)
q       % Subtract one
:       % Create an array [1...(N-1)]
Q       % Add one to create [2...N]
"       % For each element
  @Z\   % Compute the divisors of this element (including itself)
  l_)   % Grab the next to last element (the largest that isn't itself)
  v     % Vertically concatenate the entire stack so far
  s     % Sum the result
```
[Answer]
# [PHP](https://php.net/), 56 bytes
```
for($i=1;$v||$argn>=$v=++$i;)$i%--$v?:$v=!$s+=$v;echo$s;
```
[Try it online!](https://tio.run/##K8go@G9jX5BRwJVaVJRfFF@UWpBfVJKZl65R5xrv5x/i6eyqac2lkliUnmerZGhgYKBk/T8tv0hDJdPW0FqlrKYGLGVnq1Jmq62tkmmtqZKpqqurUmZvBRRRVCnWBspYpyZn5KsUW///DwA "PHP – Try It Online")
[Answer]
# [Prolog (SWI)](http://www.swi-prolog.org), 72 bytes
```
f(A,B):-A=2,B=1;C is A-1,f(C,D),between(2,A,E),divmod(A,E,S,0),B is D+S.
```
[Try it online!](https://tio.run/##FcyxDkAwGEXhVzH2j1tpjcTQap/AYhatNEFFhccv9vOd44xrXHh6Qs6eKWhquOpq6E62fRFSobiEZz0MYXLX49zOaihYwhzuLc6fsRggCPrPTTlU/0kKITBS9QI "Prolog (SWI) – Try It Online")
[Answer]
# [Cubix](https://github.com/ETHproductions/cubix), 27 ~~39~~ bytes
```
?%\(W!:.U0IU(;u;p+qu.@Op\;;
```
[Try it online!](https://tio.run/##Sy5Nyqz4/99eNUYjXNFKL9TAM1TDutS6QLuwVM/BvyDG2vr/f0MDAwMA "Cubix – Try It Online")
Cubified
```
      ? % \
      ( W !
      : . U
0 I U ( ; u ; p + q u .
@ O p \ ; ; . . . . . .
. . . . . . . . . . . .
      . . .
      . . .
      . . .
```
[Watch It Run](https://ethproductions.github.io/cubix/?code=ICAgICAgPyAlIFwKICAgICAgKCBXICEKICAgICAgOiAuIFUKMCBJIFUgKCA7IHUgOyBwICsgcSB1IC4KQCBPIHAgXCA7IDsgLiAuIC4gLiAuIC4KLiAuIC4gLiAuIC4gLiAuIC4gLiAuIC4KICAgICAgLiAuIC4KICAgICAgLiAuIC4KICAgICAgLiAuIC4K&input=OAo=&speed=20)
* `0IU` Set up the stack with an accumulator, and the starting integer. U-turn into the outer loop
* `:(?` duplicate the current top of stack, decrement and test
* `\pO@` if zero loop around the cube to a mirror, grab the bottom of stack, output and halt
* `%\!` if positive, mod, relect and test.
	+ `u;.W` if truthy, u-turn, remove mod result and lane change back into inner loop
	+ `U;p+qu;;\(` if falsey, u-turn, remove mod result, bring accumulator to top, add current integer (top) divisor push to bottom and u-turn. Clean up the stack to have just accumulator and current integer, decrement the integer and enter the outer loop again.
[Answer]
# [C# (.NET Core)](https://www.microsoft.com/net/core/platform), 74 72 bytes
```
n=>{int r=0,j;for(;n>1;n--)for(j=n;--j>0;)if(n%j<1){r+=j;j=0;}return r;}
```
[Try it online!](https://tio.run/##lY8/a8MwEMV3f4pbChKNEtn5jyIvhU4tFDp0NopcJJITSEqhGH921w52vXRQ33Do7vTjvVOBKed1B73UpQoB3rz79NU1GybNvQ4KsYpGwZczZ3itDBL6u5o/DXr/DlFfl883VCeDcQF9KaEGmXUoy6bvwEu@sKJ2nggsc4GM0aGxEgVjtuSCmprggz3ltPGP0goruWi9jjeP4EXbiewvyyeHwV308sObqF8MalKTglIBqxXkqcBmBDapwG4EDqnAYYq0TiXy7RQq@Yz1fkSK4phsw/kUbXfk/6BmbFvsZ7v2/mq7Hw "C# (.NET Core) – Try It Online")
* 2 bytes shaved thanks to Kevin Cruijssen.
[Answer]
# [Actually](https://github.com/Mego/Seriously), 12 bytes
```
u2x⌠÷R1@E⌡MΣ
```
[Try it online!](https://tio.run/##S0wuKU3Myan8/7/UqOJRz4LD24MMHVwf9Sz0Pbf4/39DAwMDAA "Actually – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), ~~78 75 73~~ 71 bytes
Not even close to Leaky nun's python answer in byte count.
```
f=lambda z:sum(max(i for i in range(1,y)if 1>y%i)for y in range(2,z+1))
```
[Try it online!](https://tio.run/##RclLCoAgEADQq8wmmCEXWrug7mKUNZAfzCC9vNWq5eOFnHbv@lrNeGg7LxrKcF4Wrb6RwfgIDOwgaretqEQmNqCm3DB9l//rRGkVUQ2RXUKDSkr58gE "Python 3 – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), ~~69~~ ~~63~~ 59 bytes
4 bytes thanks to Dennis.
```
f=lambda n:n-1and max(j for j in range(1,n)if n%j<1)+f(n-1)
```
[Try it online!](https://tio.run/##Tc5bCoMwEAXQf1cxUAoJfZDEd2kXk1bTRswoMYW6ehulxg7Mz@HeYfrRvTqMJ236zjoYxiHyex5qZ@vH2w66w1Yb7YhgjNFJ3Vpp7pUEvOCJS6zAyA9pQHUWGtAIVuKzJvyIVCvAfXPl9KCIz9KptxodUURQCn52wKOVkpWSQNlKRaAiFONgPF3QN7drcf4zIcot6N@nSzkr2b/OPGsq8nL6Ag "Python 3 – Try It Online")
I set the recursion limit to 2000 for this to work for 1000.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 37 bytes
```
Ａ⁰βＦ…·²Ｎ«Ａ⟦⟧δＦ⮌…¹ι«¿¬﹪ικ⊞δκ»Ａ⁺β⌈δβ»Ｉβ
```
[Try it online!](https://tio.run/##Nc69CoMwFAXg3afIeC9E0K5O0slBEdfSITFRgzEp@ZFC8dlTWtv1cL7DGRfmRst0SrX3ajZQUMKxyibrCDRm1NGrXQ7MzBIulDTmEUMXNy4dICJ5ZT92u1Mi/m6Qu3RewslKqr5VNRHobIDWiqgtKLp@4j76BQQlK1bHf6wWAjglLXuqLW4gEM9TR9Y7ZQJcmQ/AEauUyqJI@Z5yr98 "Charcoal – Try It Online")
Link is to the verbose version. It took me almost all day to figure out how could I solve a non-ASCII-art-related question in Charcoal, but finally I got it and I am very proud of me. :-D
Yes, I am sure this can be golfed a lot. I just translated my C# answer and I am sure things can be done differently in Charcoal. At least it solves the `1000` case in a couple of seconds...
[Answer]
# [Pari/GP](http://pari.math.u-bordeaux.fr/), ~~36~~ 30 bytes
```
n->sum(i=2,n,i/divisors(i)[2])
```
[Try it online!](https://tio.run/##HYxBCoMwEEWv8nGVwARjWqubeBHpQiiWgXYcEi309DHt5r/3Nl@XxO6pZUUs4qZ8vA3HQELcPvjDeUvZsJ3D3ZZF9fU1AjdBE8tetflFg9WItYQ5EK6EG2EkdD3hMlR6/x9fH04 "Pari/GP – Try It Online")
[Answer]
# [Python 2 (PyPy)](http://pypy.org/), 145 bytes
Because turning code-golf competitions into fastest-code competitions is fun, here is an O(*n*) algorithm that, on TIO, solves *n* = **5,000,000,000** in 30 seconds. ([Dennis’s sieve](https://codegolf.stackexchange.com/a/128176/39242) is O(*n* log *n*).)
```
import sympy
n=input()
def g(i,p,k,s):
 while p*max(p,k)<=n:l=k*p;i+=1;p=sympy.sieve[i];s-=g(i,p,l,n/l*(n/l*k+k-2)/2)
 return s
print~g(1,2,1,-n)
```
[Try it online!](https://tio.run/##NYy9DsIgFEZ3noIRWrCWxMXKkxgHE7G9gd7eAFVZfHX8i99whpOcj0qeFjSaCpVaYaYlZp7KTIWhBaQ1C8ku7spHAYqUV0nuGb9PEBynZj4/xFvKg8V9sL6hAVrbD2S/D5sE7uaOcBqStr8@KOxCIz7wrddGdkYyHl1eI/LEKALm5yh6ZVSvNMpad9v/Xg "Python 2 (PyPy) – Try It Online")
### How it works
We count the size of the set
*S* = {(*a*, *b*) | 2 ≤ *a* ≤ *n*, 2 ≤ *b* ≤ largest-proper-divisor(*a*)},
by rewriting it as the union, over all primes p ≤ √n, of
*S**p* = {(*p*⋅*d*, *b*) | 2 ≤ *d* ≤ *n*/*p*, 2 ≤ *b* ≤ *d*},
and using the [inclusion–exclusion principle](https://en.wikipedia.org/wiki/Inclusion%E2%80%93exclusion_principle):
|*S*| = ∑ (−1)*m* − 1 |*S**p*1 ∩ ⋯ ∩ *S**p**m*| over *m* ≥ 1 and primes *p*1 < ⋯ < *p**m* ≤ √n,
where
*S**p*1 ∩ ⋯ ∩ *S**p**m* = {(*p*1⋯*p**m*⋅*e*, *b*) | 1 ≤ *e* ≤ *n*/(*p*1⋯*p**m*), 2 ≤ *b* ≤ *p*1⋯*p**m* − 1*e*},  
|*S**p*1 ∩ ⋯ ∩ *S**p**m*| = ⌊*n*/(*p*1⋯*p**m*)⌋⋅(*p*1⋯*p**m* − 1⋅(⌊*n*/(*p*1⋯*p**m*)⌋ + 1) − 2)/2.
The sum has *C*⋅*n* nonzero terms, where *C* converges to some constant that’s probably 6⋅(1 − ln 2)/π2 ≈ 0.186544. The final result is then |*S*| + *n* − 1.
[Answer]
# [NewStack](https://github.com/LyamBoylan/NewStack/), 5 bytes
Luckily, there's actually a built in.
```
Nᵢ;qΣ
```
## The breakdown:
```
Nᵢ       Add the first (user's input) natural numbers to the stack.
  ;      Perform the highest factor operator on whole stack.
   q     Pop bottom of stack.
    Σ    Sum stack.
```
**In actual English:**
Let's run an example for an input of 8.
`Nᵢ`: Make list of natural numbers from 1 though 8: `1, 2, 3, 4, 5, 6, 7, 8`
`;`: Compute the greatest factors: `1, 1, 1, 2, 1, 3, 1, 4`
`q`. Remove the first element: `1, 1, 2, 1, 3, 1, 4`
`Σ` And take the sum: `1+1+2+1+3+1+4` = `13`
[Answer]
# Java 8, ~~78~~ ~~74~~ 72 bytes
```
n->{int r=0,j;for(;n>1;n--)for(j=n;j-->1;)if(n%j<1){r+=j;j=0;}return r;}
```
[Port of *@CarlosAlejo*'s C# answer.](https://codegolf.stackexchange.com/a/128169/52210)
[Try it here.](https://tio.run/##hY7BasMwEETv@Yq9FCRaGTtN2sBG@YPkkmPpQVXkItVZG1kOBKNvd@Qk1yJYLey8YTROXZRoO0Pu9DfpRvU97JWlcQFgKRhfK23gMJ93ATSbN3FMSkwvTR9UsBoOQCBhIrEbZ4uX5ZvDuvUMaVchCcHnw0lCJ0RSuK0ZvbhtxUf/Kh06WWL0JgyewGOc8JHeDT9NSn9@cmntCc6pIDsGb@n36xsUf7Q7XvtgzkU7hKJLKDTEqNBsye9d/@WrDP/I8E2GV@uM4f0zl1CWecfTEhdxugE)
**Old answer (78 bytes):**
```
n->{int r=0,i=1,j,k;for(;++i<=n;r+=k)for(j=1,k=1;++j<i;k=i%j<1?j:k);return r;}
```
[Try it here.](https://tio.run/##hY7NasMwEITveYq9FCTsGLs/Sams9gmaS46lB0VRwkrO2shyoAQ/uysnuQbBakHzDTtj1Vkt286Q3btJN6rv4VshXRYASMH4g9IGNvP3KoBm8yYuojLGF6cPKqCGDRBImGj5eZktXpY5yiq3uROH1jORZVhLEj6Tjs@CjdDJKuq2RuEkPtm6@rIfjgtvwuAJvBgnccvohl0TM@5R5xb3cIo12TZ4pOPPLyh@67j964M5Fe0Qii6i0BCjQrNnfm38kL8m@CrB3xO8eksYXtapC2WZdtwt42Kc/gE)
**Explanation (of old answer):**
```
n->{                    // Method with integer parameter and integer return-type
  int r=0,              //  Result-integers
      i=1,j,k;          //  Some temp integers
  for(;++i<=n;          //  Loop (1) from 2 to `n` (inclusive)
      r+=k)             //    And add `k` to the result after every iteration
    for(j=1,k=1;++j<i;  //   Inner loop (2) from `2` to `i` (exclusive)
      k=i%j<1?j:k       //    If `i` is dividable by `j`, replace `k` with `j`
    );                  //   End of inner loop (2)
                        //  End of loop (2) (implicit / single-line body)
  return r;             //  Return result-integer
}                       // End of method
```
[Answer]
# [Thunno 2](https://github.com/Thunno/Thunno2) `-S`, 5 [bytes](https://github.com/Thunno/Thunno2/blob/main/docs/codepage.md)
```
ı⁺FṫG
```
[Try it online!](https://Not-Thonnu.github.io/run#aGVhZGVyPSZjb2RlPSVDNCVCMSVFMiU4MSVCQUYlRTElQjklQUJHJmZvb3Rlcj0maW5wdXQ9NiZmbGFncz0tU2U=)
#### Explanation
```
ı⁺FṫG  # Implicit input
       # Decrement the input
ı      # Map over [1..input-1]:
 ⁺     #  Increment the number
  Fṫ   #  Push the proper divisors
    G  #  Maximum of this list
       # Sum the list
       # Implicit output
```
[Answer]
# [Arturo](https://arturo-lang.io), 32 bytes
```
$=>[∑map..2&=>[x:do factors&]]
```
[Try it!](http://arturo-lang.io/playground?B7ePFw)
[Answer]
# [Lua](https://www.lua.org), 74 bytes
```
c=0 for i=2,...do for j=1,i-1 do t=i%j<1 and j or t end c=c+t end print(c)
```
[Try it online!](https://tio.run/##JcnRCoAgDEDRX9lLUGSy9dw@RmbBJDTEvn9Jvt3Dvd9gJoxwlQrKu/Pex/IrMTndCDob65QOgpAjJOivwdlTWNZRT9XcZlnMjBDxAw "Lua – Try It Online")
[Answer]
# [J](http://jsoftware.com/), 18 bytes
```
[:+/1}.&.q:@+}.@i.
```
[Try it online!](https://tio.run/##y/r/P83WKtpKW9@wVk9Nr9DKQbtWzyFT739qcka@QpqCoYGBwX8A "J – Try It Online")
]