%I #33 Sep 08 2022 08:46:24
%S 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,
%T 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,
%U 8,12,8,2,4,8,16,2,24,2,0,14,4,8,16,2,24,17
%N a(n) = Sum_{d|n} d & (n/d), where & is the bitwise AND operator, with a(0) = 0.
%H Antti Karttunen, <a href="/A327987/b327987.txt">Table of n, a(n) for n = 0..16384</a>
%F a(n) is odd if and only if n is an odd square (A016754).
%p A327987 := n -> add(Bits:-And(d, n/d), d=numtheory:-divisors(n)):
%p seq(A327987(n), n=0..81);
%t divisors[0] := {}; divisors[n_] := Divisors[n];
%t a[n_] := Total[Table[BitAnd[d , n/d], {d, divisors[n]}]] ;
%t Table[a[n], {n, 0, 81}]
%o (Sage) def a(n): return sum(d & n//d for d in divisors(n)) if n > 0 else 0
%o print([a(n) for n in (0..81)])
%o (PARI) a(n) = if (n, sumdiv(n, d, bitand(d, n/d)), 0); \\ _Michel Marcus_, Oct 11 2019
%o (Magma) [0] cat [&+[BitwiseAnd(d,n div d):d in Divisors(n)]:n in [1..90]]; // _Marius A. Burtea_, Oct 11 2019
%o (Julia)
%o using IntegerSequences
%o vcat([0], [V327987(n) for n in 1:81]) |> println # _Peter Luschny_, Sep 25 2021
%Y Cf. A327988 (zeros), A327989, A016754.
%K nonn
%O 0,4
%A _Peter Luschny_, Oct 11 2019
|