login
A367368
a(n) = Sum_{(n - k) does not divide n, 0 <= k <= n} k.
2
0, 1, 2, 4, 5, 11, 9, 22, 19, 31, 33, 56, 34, 79, 73, 84, 87, 137, 102, 172, 132, 179, 201, 254, 168, 281, 289, 310, 294, 407, 297, 466, 399, 477, 513, 538, 433, 667, 649, 680, 590, 821, 663, 904, 810, 843, 969, 1082, 820, 1135, 1068, 1194, 1164, 1379, 1173
OFFSET
0,3
COMMENTS
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.
REFERENCES
Tom M. Apostol, Introduction to Analytic Number Theory, Springer 1976, p. 14.
FORMULA
An additive decomposition of the triangular numbers:
a(n) + A094471(n) = A000217(n) for n >= 0 assuming A094471 with correct offset 0.
MAPLE
# Warning: Be careful when using the deprecated 'numtheory' package.
# It might not handle the case n = 0 correctly. A better solution is:
divides := (k, n) -> k = n or (k > 0 and irem(n, k) = 0):
A367368 := n -> local k; add(`if`(divides(n - k, n), 0, k), k = 0..n):
seq(A367368(n), n = 0..61);
MATHEMATICA
a[n_]:=n+Sum[k*Boole[!Divisible[n, n-k]], {k, 0, n-1}]; Array[a, 55, 0] (* Stefano Spezia, Nov 15 2023 *)
PROG
(SageMath)
def A367368(n): return sum(k for k in (0..n) if not (n - k).divides(n))
print([A367368(n) for n in range(55)])
(Julia)
using AbstractAlgebra
function A367326(n) sum(k for k in 0:n if ! is_divisible_by(n, n - k)) end
[A367326(n) for n in 0:54] |> println
(Python)
def divides(k, n): return k == n or ((k > 0) and (n % k == 0))
def A367368(n): return sum(k for k in range(n + 1) if not divides(n - k, n))
print([A367368(n) for n in range(55)])
(Python)
from math import prod
from sympy import factorint
def A367368(n):
f = factorint(n).items()
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
CROSSREFS
Cf. A094471 (the not negated case), A000217.
Sequence in context: A248127 A258253 A177244 * A296346 A089409 A287269
KEYWORD
nonn
AUTHOR
Peter Luschny, Nov 15 2023
STATUS
approved