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.

A327987 a(n) = Sum_{d|n} d & (n/d), where & is the bitwise AND operator, with a(0) = 0.

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