A382483 a(n) = smallest number k such that at least one of sigma(n) - k and sigma(n) + k is a perfect number.
5, 3, 2, 1, 0, 6, 2, 9, 7, 10, 6, 0, 8, 4, 4, 3, 10, 11, 8, 14, 4, 8, 4, 32, 3, 14, 12, 28, 2, 44, 4, 35, 20, 26, 20, 63, 10, 32, 28, 62, 14, 68, 16, 56, 50, 44, 20, 96, 29, 65, 44, 70, 26, 92, 44, 92, 52, 62, 32, 140, 34, 68, 76, 99, 56, 116, 40, 98, 68, 116, 44, 167, 46, 86, 96, 112, 68, 140
Offset: 1
Examples
sigma(6) = 12, the nearest perfect number is 6, thus a(6) = 12 - 6 = 6. sigma(26) = 42, the nearest perfect number is 28, thus a(26) = 42 - 28 = 14.
Programs
-
Maple
isA000396 := proc(n::integer) if n < 6 then false ; elif numtheory[sigma](n) = 2*n then true; else false; end if; end proc: A382483 := proc(n) local k ; for k from 0 do if isA000396(numtheory[sigma](n)-k) or isA000396(numtheory[sigma](n)+k) then return k; end if; end do: end proc: seq(A382483(n),n=1..50) ; # R. J. Mathar, Apr 01 2025
-
PARI
isp(x) = if (x>0, sigma(x) == 2*x); a(n) = my(k=0, s=sigma(n)); while (!(isp(s-k) || isp(s+k)), k++); k; \\ Michel Marcus, Apr 01 2025