This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A367368 #17 Nov 17 2023 11:21:15 %S A367368 0,1,2,4,5,11,9,22,19,31,33,56,34,79,73,84,87,137,102,172,132,179,201, %T A367368 254,168,281,289,310,294,407,297,466,399,477,513,538,433,667,649,680, %U A367368 590,821,663,904,810,843,969,1082,820,1135,1068,1194,1164,1379,1173 %N A367368 a(n) = Sum_{(n - k) does not divide n, 0 <= k <= n} k. %C A367368 The case n = 0 is well defined because zero divides zero. When implementing the sequence it is advisable to use the definition of divisibility of an integer directly and not the set of divisors, because this is infinite in the case n = 0 and, therefore, cannot be represented in computer algebra systems, which leads to a wide variety of error messages depending on the system. Some of these error messages are in turn incorrect, because the test of divisibility by zero does not involve division and therefore should not lead to a 'ZeroDivisionError' or similar. %D A367368 Tom M. Apostol, Introduction to Analytic Number Theory, Springer 1976, p. 14. %F A367368 An additive decomposition of the triangular numbers: %F A367368 a(n) + A094471(n) = A000217(n) for n >= 0 assuming A094471 with correct offset 0. %p A367368 # Warning: Be careful when using the deprecated 'numtheory' package. %p A367368 # It might not handle the case n = 0 correctly. A better solution is: %p A367368 divides := (k, n) -> k = n or (k > 0 and irem(n, k) = 0): %p A367368 A367368 := n -> local k; add(`if`(divides(n - k, n), 0, k), k = 0..n): %p A367368 seq(A367368(n), n = 0..61); %t A367368 a[n_]:=n+Sum[k*Boole[!Divisible[n,n-k]],{k,0,n-1}]; Array[a,55,0] (* _Stefano Spezia_, Nov 15 2023 *) %o A367368 (SageMath) %o A367368 def A367368(n): return sum(k for k in (0..n) if not (n - k).divides(n)) %o A367368 print([A367368(n) for n in range(55)]) %o A367368 (Julia) %o A367368 using AbstractAlgebra %o A367368 function A367326(n) sum(k for k in 0:n if ! is_divisible_by(n, n - k)) end %o A367368 [A367326(n) for n in 0:54] |> println %o A367368 (Python) %o A367368 def divides(k, n): return k == n or ((k > 0) and (n % k == 0)) %o A367368 def A367368(n): return sum(k for k in range(n + 1) if not divides(n - k, n)) %o A367368 print([A367368(n) for n in range(55)]) %o A367368 (Python) %o A367368 from math import prod %o A367368 from sympy import factorint %o A367368 def A367368(n): %o A367368 f = factorint(n).items() %o A367368 return (n*(n+1)>>1)-n*prod(e+1 for p,e in f)+prod((p**(e+1)-1)//(p-1) for p,e in f) if n else 0 # _Chai Wah Wu_, Nov 17 2023 %Y A367368 Cf. A094471 (the not negated case), A000217. %K A367368 nonn %O A367368 0,3 %A A367368 _Peter Luschny_, Nov 15 2023