З огляду на те, що у вас є нескінченна послідовність чисел, визначена наступним чином:
1: 1 = 1
2: 1 + 2 = 3
3: 1 + 3 = 4
4: 1 + 2 + 4 = 7
5: 1 + 5 = 6
6: 1 + 2 + 3 + 6 = 12
7: 1 + 7 = 8
...
Послідовність - це сума дільників n
, включаючи 1 і n
.
Задавши ціле додатне ціле число x
, обчисліть найменше число, n
яке дасть результат, більший за x
.
Тестові справи
f(100) = 48, ∑ = 124
f(25000) = 7200, ∑ = 25389
f(5000000) = 1164240, ∑ = 5088960
Очікуваний вихід
Ваша програма повинна повернути і обидва, n
і суму її дільників, наприклад:
$ ./challenge 100
48,124
Правила
Це код-гольф, тому найкоротший код у байтах, виграючи кожну мову.
n
і інше f(n)
, але ви цього не говорите ніде в специфікації.
f(1000) = 48
? Сума дільника 48
становить124
n
дільників s? Ви, ймовірно, захочете це прямо сказати.