login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A367368 a(n) = Sum_{(n - k) does not divide n, 0 <= k <= n} k. 2

%I #17 Nov 17 2023 11:21:15

%S 0,1,2,4,5,11,9,22,19,31,33,56,34,79,73,84,87,137,102,172,132,179,201,

%T 254,168,281,289,310,294,407,297,466,399,477,513,538,433,667,649,680,

%U 590,821,663,904,810,843,969,1082,820,1135,1068,1194,1164,1379,1173

%N a(n) = Sum_{(n - k) does not divide n, 0 <= k <= n} k.

%C 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 Tom M. Apostol, Introduction to Analytic Number Theory, Springer 1976, p. 14.

%F An additive decomposition of the triangular numbers:

%F a(n) + A094471(n) = A000217(n) for n >= 0 assuming A094471 with correct offset 0.

%p # Warning: Be careful when using the deprecated 'numtheory' package.

%p # It might not handle the case n = 0 correctly. A better solution is:

%p divides := (k, n) -> k = n or (k > 0 and irem(n, k) = 0):

%p A367368 := n -> local k; add(`if`(divides(n - k, n), 0, k), k = 0..n):

%p seq(A367368(n), n = 0..61);

%t a[n_]:=n+Sum[k*Boole[!Divisible[n,n-k]],{k,0,n-1}]; Array[a,55,0] (* _Stefano Spezia_, Nov 15 2023 *)

%o (SageMath)

%o def A367368(n): return sum(k for k in (0..n) if not (n - k).divides(n))

%o print([A367368(n) for n in range(55)])

%o (Julia)

%o using AbstractAlgebra

%o function A367326(n) sum(k for k in 0:n if ! is_divisible_by(n, n - k)) end

%o [A367326(n) for n in 0:54] |> println

%o (Python)

%o def divides(k, n): return k == n or ((k > 0) and (n % k == 0))

%o def A367368(n): return sum(k for k in range(n + 1) if not divides(n - k, n))

%o print([A367368(n) for n in range(55)])

%o (Python)

%o from math import prod

%o from sympy import factorint

%o def A367368(n):

%o f = factorint(n).items()

%o 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 Cf. A094471 (the not negated case), A000217.

%K nonn

%O 0,3

%A _Peter Luschny_, Nov 15 2023

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 6 17:40 EDT 2024. Contains 374981 sequences. (Running on oeis4.)