A proper divisor is a 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).
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 apply.
You can take input and provide output by any standard method.
This is code-golf, the shortest valid submission in each language wins! Have Fun!