login
A327987
a(n) = Sum_{d|n} d & (n/d), where & is the bitwise AND operator, with a(0) = 0.
4
0, 1, 0, 2, 2, 2, 4, 2, 0, 5, 0, 2, 4, 2, 4, 4, 4, 2, 4, 2, 12, 8, 4, 2, 8, 7, 0, 4, 12, 2, 16, 2, 0, 8, 0, 12, 10, 2, 4, 4, 0, 2, 16, 2, 4, 10, 4, 2, 8, 9, 0, 4, 12, 2, 8, 4, 8, 8, 0, 2, 24, 2, 4, 6, 8, 12, 8, 2, 4, 8, 16, 2, 24, 2, 0, 14, 4, 8, 16, 2, 24, 17
OFFSET
0,4
LINKS
FORMULA
a(n) is odd if and only if n is an odd square (A016754).
MAPLE
A327987 := n -> add(Bits:-And(d, n/d), d=numtheory:-divisors(n)):
seq(A327987(n), n=0..81);
MATHEMATICA
divisors[0] := {}; divisors[n_] := Divisors[n];
a[n_] := Total[Table[BitAnd[d , n/d], {d, divisors[n]}]] ;
Table[a[n], {n, 0, 81}]
PROG
(Sage) def a(n): return sum(d & n//d for d in divisors(n)) if n > 0 else 0
print([a(n) for n in (0..81)])
(PARI) a(n) = if (n, sumdiv(n, d, bitand(d, n/d)), 0); \\ Michel Marcus, Oct 11 2019
(Magma) [0] cat [&+[BitwiseAnd(d, n div d):d in Divisors(n)]:n in [1..90]]; // Marius A. Burtea, Oct 11 2019
(Julia)
using IntegerSequences
vcat([0], [V327987(n) for n in 1:81]) |> println # Peter Luschny, Sep 25 2021
CROSSREFS
Cf. A327988 (zeros), A327989, A016754.
Sequence in context: A308042 A335694 A084862 * A216650 A027387 A226534
KEYWORD
nonn
AUTHOR
Peter Luschny, Oct 11 2019
STATUS
approved