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.

A384212 a(n) is the number of bases >= 2 in which the alternating sum of digits of n is equal to 0.

This page as a plain text file.
%I A384212 #19 Jun 03 2025 17:49:23
%S A384212 0,0,1,1,1,2,1,2,2,2,1,4,1,2,3,3,1,4,1,3,2,2,1,6,2,2,3,4,1,6,1,4,3,2,
%T A384212 2,7,1,2,3,6,1,5,1,4,5,2,1,8,2,3,3,4,1,5,2,6,3,2,1,9,1,2,5,5,3,6,1,4,
%U A384212 2,6,1,10,1,2,5,4,2,5,1,8,3,2,1,8,3,2,2
%N A384212 a(n) is the number of bases >= 2 in which the alternating sum of digits of n is equal to 0.
%C A384212 The alternating sum of digits of n is equal to 1 for base n and equal to n for bases > n.
%H A384212 Felix Huber, <a href="/A384212/b384212.txt">Table of n, a(n) for n = 1..10000</a>
%F A384212 Trivial bounds: 1 <= a(n) <= n - 2 for n >= 3 because the representation of n in base n-1 is [1,1] and the alternating sum of digits of n is > 0 for bases >= n.
%e A384212 a(72) = 10 because the alternating sum of digits of n is equal to 0 in the 10 bases 2 [1, 0, 0, 1, 0, 0, 0], 3 [2, 2, 0, 0], 5 [2, 4, 2], 7 [1, 3, 2], 8 [1, 1, 0], 11 [6, 6], 17 [4, 4], 23 [3, 3], 35 [2, 2] and 71 [1, 1].
%p A384212 A384212:=proc(n)
%p A384212     local a,b,c,i;
%p A384212     a:=0;
%p A384212     for b from 2 to n-1 do
%p A384212         c:=convert(n,'base',b);
%p A384212     	   if add(c[i]*(-1)^i,i=1..nops(c))=0 then
%p A384212            a:=a+1
%p A384212         fi
%p A384212     od;
%p A384212     return a
%p A384212 end proc;
%p A384212 seq(A384212(n),n=1..87);
%p A384212 A384212bases:=proc(n)
%p A384212     local L,b,c,i;
%p A384212     L:=[];
%p A384212     for b from 2 to n-1 do
%p A384212         c:=convert(n,'base',b);
%p A384212     	if add(c[i]*(-1)^i,i=1..nops(c))=0 then
%p A384212             L:=[op(L),b,ListTools:-Reverse(c)]
%p A384212         fi
%p A384212     od;
%p A384212     return op(L)
%p A384212 end proc;
%p A384212 A384212bases(72);
%t A384212 q[n_, b_] := Module[{d = IntegerDigits[n, b]}, Sum[(-1)^k*d[[k]], {k, 1, Length[d]}] == 0 ]; a[n_] := Count[Range[2, n-1], _?(q[n, #] &)]; Array[a, 100] (* _Amiram Eldar_, May 24 2025 *)
%o A384212 (Python)
%o A384212 from sympy.ntheory import digits
%o A384212 def s(v): return sum(v[::2]) - sum(v[1::2])
%o A384212 def a(n): return sum(1 for b in range(2, n) if s(digits(n, b)[1:]) == 0)
%o A384212 print([a(n) for n in range(1, 87)]) # _Michael S. Branicky_, May 24 2025
%o A384212 (PARI) a(n) = sum(b=2, n-1, my(d=digits(n, b)); sum(k=1, #d, (-1)^k*d[k]) == 0); \\ _Michel Marcus_, May 24 2025
%Y A384212 Cf. A055240, A061845, A225693, A135499, A135551, A384211.
%K A384212 nonn,base
%O A384212 1,6
%A A384212 _Felix Huber_, May 24 2025