%I #17 Oct 26 2014 04:54:42
%S 0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
%T 0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,
%U 1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
%N Number of bases b for which the base-b alternate digital sum of n is -b.
%C For the definition of the alternate digital sum, see A055017 or A225693.
%C For reference: we write altDigitSum_b(x) for the base-b alternate digital sum of x according to A055017.
%C The number of counted bases includes the special base 1. The base-1 expansion of a natural number is defined as 1=1_1, 2=11_1, 3=111_1 and so on. As a result, the base-1 alternate digital sum is 0 if n is even, and is 1 if n is odd.
%C The altDigitSum_b(n) is > -b for bases b that satisfy b > b0 := floor((n - floor(n^(1/3))*(floor(n^(1/3))-1))^(1/3)), and thus a(n) <= b0.
%C If n is the sum of a cube m^3 and an oblong number m*(m-1) (see A002378), then, with b := m, b^3 + b(b-1) = n and b = b0. This implies altDigitSum_b(n) = 0 - (b-1) + 0 - 1 = -b and shows that there are infinitely many n with a base b > 1 such that altDigitSum_b(n) = -b. Consequently, a(n) >= 1 infinitely often (for those n > 1 that are the sum of a cube and an oblong number, i.e., n = 10, 33, 76, 145, 246, ...).
%C Moreover, a(n) >= 1 is also true for n == b(b(b+1)-1) (mod (b+1)b^4), b>1.
%C Example 1: altDigitSum_2(n) = -2 for n == 10 (mod 48).
%C Example 2: altDigitSum_3(n) = -3 for n == 33 (mod 324).
%C Example 3: altDigitSum_4(n) = -4 for n == 76 (mod 1280).
%C If b is a base such that the base-b alternate digital sum of n is -b, then b + 1 is a divisor of n - 1. Thus, the number of such bases is also limited by the number of divisors of n - 1 (see formula section).
%C If b + 1 is a divisor of n - 1, then b is not necessarily a base such that base-b alternate digital sum of n is -b. Example: 2, 4, 8 and 16 are divisors of 32 and altDigitSum_3(33) = -3, but altDigitSum_1(33) = 1, altDigitSum_7(33) = 1, altDigitSum_15(33) = 1.
%C a(b*n) > 0 for all b > 1 that satisfy altDigitSum_b(n) = b.
%C Example 4: altDigitSum_2(5) = 2, hence a(2*5) > 0.
%C Example 5: altDigitSum_3(11) = 3, hence a(3*11) > 0.
%C The first n with a(n) = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ... are n = 10, 136, 385, 2241, 24781, 26797, 175561, 182401, 374221, 475021, ... .
%H Hieronymus Fischer, <a href="/A239705/b239705.txt">Table of n, a(n) for n = 1..10000</a>
%F a(n^3 + A002378(n-1)) = a(n^3 + n^2 - n) >= 1, n > 1.
%F a(n) = 0, if n - 1 is a prime.
%F A239703(n) = 0 ==> a(n) = 0.
%F a(A187813(n) = 0.
%F a(n) <= floor(sigma_0(n-1)/2).
%e a(1) = 0, since altDigitSum_1(1) = 1 and altDigitSum_b(1) = 1 > -b for all b > 1.
%e a(2) = 0, since altDigitSum_1(2) = 0 (because of 2 = 11_1), and altDigitSum_2(2) = -1 (because of 2 = 10_2), and altDigitSum_b(2) = 2 > -b for all b > 2.
%e a(3) = 0, since altDigitSum_1(3) = 1 (because of 3 = 111_1), and altDigitSum_2(3) = 0 (because of 3 = 11_2), and altDigitSum_3(3) = -1 (because of 3 = 10_3), and altDigitSum_b(3) = 3 > -b for all b > 3.
%e a(10) = 1, since altDigitSum_1(10) = 0, and altDigitSum_2(10) = -2 (because of 10 = 1010_2), and altDigitSum_3(10) = 2 (because of 10 = 101_3), and altDigitSum_4(10) = 0 (because of 10 = 22_4), and altDigitSum_5(10) = -2 (because of 10 = 20_5), ..., and altDigitSum_b(10) = 10 > -b for all b > 10.
%o (Smalltalk)
%o "> Version 1: simple calculation for small numbers.
%o Answer the number of bases b for which the alternate digital sum of n in base b is -b.
%o Valid for bases b > 0.
%o Using altDigitalSumRight from A055017.
%o Usage: n numOfBasesWithAltDigitalSumEQ0
%o Answer: a(n)"
%o numOfBasesWithAltDigitalSumEQNegBase
%o | b q numBases |
%o self < 10 ifTrue: [^0].
%o numBases := 0.
%o q := self cubeRootTruncated.
%o b := 1.
%o [b < q] whileTrue:[
%o (self altDigitalSumRight: b) = 0
%o ifTrue: [numBases := numBases + 1].
%o b := b + 1].
%o ^numBases
%o [by _Hieronymus Fischer_, May 08 2014]
%o -----------
%o (Smalltalk)
%o "> Version 2: accelerated calculation for large numbers.
%o Answer the number of bases b for which the alternate
%o digital sum of n in base b is -b.
%o Valid for bases b > 0.
%o Using altDigitalSumRight from A055017.
%o Usage: n numOfBasesWithAltDigitalSumEQ0
%o Answer: a(n)"
%o numOfBasesWithAltDigitalSumEQNegBase
%o | numBases div b bsize |
%o self < 10 ifTrue: [^0].
%o div := (self - 1) divisors.
%o numBases := 0.
%o bsize := div size // 2 + 1.
%o 2 to: bsize do: [ :i | b := (div at: i) - 1.
%o (self altDigitalSumRight: b) = (b negated)
%o ifTrue: [numBases := numBases + 1]].
%o ^numBases
%o [by _Hieronymus Fischer_, May 08 2014]
%Y Cf. A055017, A225693, A187813.
%Y Cf. A239703, A239704, A239706, A239707.
%Y Cf. A002378, A008864, A000040, A000005.
%K nonn
%O 1
%A _Hieronymus Fischer_, May 08 2014