cp's OEIS Frontend

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.

Showing 1-3 of 3 results.

A367327 a(n) = Sum_{(n - k) does not divide n, 0 <= k < n} k^2.

Original entry on oeis.org

0, 0, 0, 1, 1, 14, 5, 55, 39, 104, 115, 285, 104, 506, 457, 575, 611, 1240, 790, 1785, 1204, 1950, 2349, 3311, 1746, 3924, 4155, 4625, 4312, 6930, 4375, 8555, 6939, 9032, 10127, 10845, 7887, 14910, 14549, 15603, 12730, 20540, 15273, 23821, 20648, 21874, 26905
Offset: 0

Views

Author

Peter Luschny, Nov 14 2023

Keywords

Crossrefs

Programs

  • Maple
    divides := (k, n) -> k = n or (k > 0 and irem(n, k) = 0):
    A367327 := n -> local k; add(`if`(divides(n - k, n), 0, k^2), k = 0..n - 1):
    seq(A367327(n), n = 0..61);
  • Mathematica
    a[n_] := Sum[If[Divisible[n, n - k], 0, k^2], {k, 0, n - 1}]
    Table[a[n], {n, 0, 46}]
  • PARI
    a(n) = sum(k=0, n-1, if (n % (n-k), k^2)); \\ Michel Marcus, Nov 15 2023
  • Python
    from math import prod
    from sympy import factorint
    def A367327(n):
        f = factorint(n).items()
        return n*(n-1)*((n<<1)-1)//6-n*(n*prod(e+1 for p,e in f)-(prod((p**(e+1)-1)//(p-1) for p,e in f)<<1))-prod((p**(e+1<<1)-1)//(p**2-1) for p,e in f) if n else 0 # Chai Wah Wu, Nov 14 2023
    
  • SageMath
    def A367327(n): return sum(k^2 for k in (0..n-1) if not (n-k).divides(n))
    print([A367327(n) for n in range(47)])
    

Formula

A367326(n+1) + a(n+1) = A000330(n).

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

Original entry on oeis.org

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

Views

Author

Peter Luschny, Nov 15 2023

Keywords

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.

Crossrefs

Cf. A094471 (the not negated case), A000217.

Programs

  • 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
    
  • 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 *)
  • 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
  • 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)])
    

Formula

An additive decomposition of the triangular numbers:
a(n) + A094471(n) = A000217(n) for n >= 0 assuming A094471 with correct offset 0.

A367493 a(n) = Sum_{d|n} (n-d)^n.

Original entry on oeis.org

0, 1, 8, 97, 1024, 20450, 279936, 7509953, 144295424, 4570291850, 100000000000, 4491754172274, 106993205379072, 5221973073321002, 171975117132398592, 8931527427394008833, 295147905179352825856, 20290116242888952838355, 708235345355337676357632, 51879761166564630630389778
Offset: 1

Views

Author

Chai Wah Wu, Nov 20 2023

Keywords

Crossrefs

Programs

  • Mathematica
    a[n_]:=Sum[(n-d)^n,{d,Divisors[n]}]; Array[a,20] (* Stefano Spezia, Nov 20 2023 *)
  • Python
    from sympy import divisors
    def A367493(n): return sum((n-d)**n for d in divisors(n, generator=True))

Formula

a(n) = Sum_{k=0..n} (-1)^k*binomial(n,k)*n^(n-k)*sigma_k(n).
Showing 1-3 of 3 results.