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.

A318682 a(n) is the number of odd values minus the number of even values of the integer log of all positive integers up to and including n.

This page as a plain text file.
%I A318682 #30 May 22 2025 10:21:48
%S A318682 -1,-2,-1,-2,-1,0,1,0,-1,0,1,2,3,4,3,2,3,2,3,4,3,4,5,6,5,6,7,8,9,8,9,
%T A318682 8,7,8,7,6,7,8,7,8,9,8,9,10,11,12,13,14,13,12,11,12,13,14,13,14,13,14,
%U A318682 15,14,15,16,17,16,15,14,15,16,15,14,15,14,15,16,17,18,17,16,17,18
%N A318682 a(n) is the number of odd values minus the number of even values of the integer log of all positive integers up to and including n.
%C A318682 a(n) = Sum_{k=1..n} (-1)^(sopfr(k)+1), with sopfr(n) the sum of the prime factors of n with repetition, also known as the integer log of n.
%H A318682 Daniel Blaine McBride, <a href="/A318682/b318682.txt">Table of n, a(n) for n = 1..100000</a>
%H A318682 K. Alladi and P. Erdős, <a href="http://projecteuclid.org/euclid.pjm/1102811427">On an additive arithmetic function</a>, Pacific J. Math., Volume 71, Number 2 (1977), 275-294.
%H A318682 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/SumofPrimeFactors.html">Sum of Prime Factors</a>
%F A318682 a(n) = a(n-1) + (-1)^(sopfr(n)+1) with a(1) = (-1)^(sopfr(1)+1) = -1.
%e A318682 a(4) = -1 - 1 + 1 - 1 = -2, since sopfr(1) = 0, sopfr(2) = 2, sopfr(3) = 3, and sopfr(4) = 4.
%t A318682 Nest[Append[#, #[[-1]] + (-1)^(1 + Total@ Flatten[ConstantArray[#1, #2] & @@@ FactorInteger[Length@ # + 1] ])] &, {-1}, 79] (* _Michael De Vlieger_, Sep 10 2018 *)
%o A318682 (Python)
%o A318682 from sympy import factorint
%o A318682 def A318682(n):
%o A318682     a_n = 0
%o A318682     for i in range(1, n+1):
%o A318682         a_n += (-1)**(sum(p*e for p, e in factorint(i).items())+1)
%o A318682     return a_n
%o A318682 (PARI) sopfr(n) = my(f=factor(n)); sum(k=1, #f~, f[k, 1]*f[k, 2]);
%o A318682 a(n) = sum(k=1, n, (-1)^(sopfr(k)+1)); \\ _Michel Marcus_, Sep 09 2018
%Y A318682 Cf. A001414 (sum of prime divisors of n with repetition, sopfr(n)).
%Y A318682 Cf. A036349 (numbers such that sopfr(n) is even).
%K A318682 sign
%O A318682 1,2
%A A318682 _Daniel Blaine McBride_, Aug 30 2018