A166248 a(n) is the absolute value of n minus sum of all the remainders modulo the numbers below n.
1, 2, 2, 3, 1, 3, 1, 0, 3, 3, 11, 5, 15, 17, 21, 20, 34, 29, 45, 41, 49, 55, 75, 61, 78, 86, 98, 96, 122, 108, 136, 135, 151, 163, 183, 162, 196, 210, 230, 218, 256, 242, 282, 284, 294, 312, 356, 326, 365, 370, 398, 402, 452, 438, 474, 464, 496, 520, 576, 526, 584, 610
Offset: 1
Keywords
Examples
a(1) = abs(1-0) = 1; a(2) = abs(2-0) = 2; a(3) = abs(3-1) = 2; a(4) = abs(4-1) = 3; a(5) = abs(5-4) = 1; a(6) = abs(6-3) = 3; a(7) = abs(7-8) = 1.
Programs
-
Maple
A004125 := proc(n) add( modp(n,k),k=1..n) ; end proc: A166248 := proc(n) abs(n-A004125(n)) ; end: seq(A166248(n),n=1..100) ; # R. J. Mathar, Oct 24 2009
-
Python
from math import isqrt def A166248(n): return abs(n*(n-1)+((s:=isqrt(n))**2*(s+1)-sum((q:=n//k)*((k<<1)+q+1) for k in range(1,s+1))>>1)) # Chai Wah Wu, Nov 01 2023
Formula
a(n) = abs(n - Sum_{k=1..n} (n mod k)).
a(n) = abs(n - A004125(n)). - Michel Marcus, May 08 2019
Extensions
a(19), a(20), a(37) etc. corrected by R. J. Mathar, Oct 24 2009