login
Numbers n whose base-b digit sum is not b for all bases b >= 2.
19

%I #68 Oct 11 2022 11:10:58

%S 0,1,2,4,8,14,30,32,38,42,44,54,60,62,74,84,90,98,102,104,108,110,114,

%T 128,138,140,150,152,158,164,168,174,180,182,194,198,200,212,224,228,

%U 230,234,240,242,252,270,278,282,284,294,308,312,314,318,332,338,348

%N Numbers n whose base-b digit sum is not b for all bases b >= 2.

%C Except for 1, every number is even.

%C No number ends in 6.

%C Numbers neither in A018900 nor in A226636 nor in A226969 nor in A227062 nor in A227080 nor ... . - _R. J. Mathar_, Sep 02 2013

%C From _Hieronymus Fischer_, Mar 27 2014, May 09 2014: (Start)

%C A079696 and this sequence have no terms in common.

%C Numbers which satisfy m == 1 (mod j) and m > j^2 for any j > 1 are not terms.

%C Example 1: m = 10^k, k>1, is not a term since 10^k == 1 (mod 9) and 10^k > 9^2.

%C Example 2: m = 1 + 3k, k > 3, is not a term, since m > 3(1+3) > 3^2.

%C This is the complement of the disjunction of A079696 with A239708.

%C Disregarding the first 3 terms, these are the numbers which are in A008864 but not in A239708. This leads to the following characterization: A number m > 2 is a term, i.e., satisfies digitalSum_b(m) <> b for all b > 1, if and only m is a prime number + 1 and m is not the sum of two distinct powers of 2.

%C a(6) is the only term such that a(n) = Prime(n) + 1. For n < 6, we have a(n) < Prime(n) + 1, and for n > 6, we have a(n) > Prime(n) + 1.

%C (End)

%H Hieronymus Fischer, <a href="/A187813/b187813.txt">Table of n, a(n) for n = 1..10000</a>

%F From _Hieronymus Fischer_, Mar 27 2014: (Start)

%F A239703(a(n)) = 0.

%F a(n+1) = min (p > a(n) | A239703(p) = 0)

%F [for a Smalltalk implementation see Prog section, method A187813NextTerm version 1].

%F a(n+1) = 1 + min (p > a(n) | p is prime AND ((q := p+1 - 2^floor(log_2(p+1)) = 0) OR (2^floor(log_2(q)) <> q)))

%F [for a Smalltalk implementation see Prog section, method A187813NextTerm version 2].

%F a(n) > Prime(n), for n > 5.

%F a(n - m) < Prime(n), for n > 1, where m := i*(i-1)/2 + j - 1, i := floor(log_2(Prime(n))), j := floor(log_2(Prime(n) - 2^i)).

%F a(n - m) < Prime(n), for n > 32, where m := i*(i-1)/2 + j - 16 with i and j above.

%F a(n) = Prime(n + m - 3) + 1, where m = max ( k | A239708(k) < a(n)), n > 3.

%F Remark: This identity can be used to calculate a(n) recursively. For a Smalltalk implementation see Prog section, methods A187813rec and A187813With: estimate.

%F With same conditions: a(n) = A008864(n + m - 3).

%F a(n - m + 3) = Prime(n) + 1, where m = max ( k | A239708(k) < Prime(n)), n > 3, provided Prime(n) + 1 is not a term of A239708.

%F (End)

%e 8 has binary expansion (1,0,0,0) whose digit sum 1 is not 2,

%e ternary expansion (2,2) whose digit sum 4 is not 3,

%e quaternary expansion (2,0) whose digit sum 2 is not 4,

%e 5-ary expansion (1,3) whose digit sum 4 is not 5,

%e 6-ary expansion (1,2) whose digit sum 3 is not 6,

%e 7-ary expansion (1,1) whose digit sum 2 is not 7,

%e 8-ary expansion (1,0) whose digit sum 1 is not 8,

%e and b-ary expansion (8) when b>8 whose digit sum is 8 not b. Therefore, 8 is in the sequence.

%e 3 has binary expansion (1,1) whose digit sum is 2, so 3 is not in the sequence.

%e From _Hieronymus Fischer_, Apr 10 2014: (Start)

%e a(10) = 42 (the 13th prime + 1)

%e a(100) = 618 (the 113th prime + 1)

%e a(1000) = 8172 (the 1026th prime + 1)

%e a(10^4) = 105254 (the 10042nd prime + 1)

%e a(10^5) = 1300464 (the 100056th prime + 1)

%e a(10^6) = 15486872 (the 1000063th prime + 1)

%e a(10^7) = 179425944 (the 10000071st prime + 1)

%e a(10^8) = 2038076324 (the 10^8 +84th prime + 1)

%e a(10^9) = 22801765334 (the 10^9 +92nd prime + 1)

%e a(10^10) = 252097803264 (the 10^10 +102nd prime + 1)

%e [calculation for large numbers processed with Smalltalk method A187813With: estimate; see Prog section]

%e (End)

%t Q@n_:=AllTrue[Table[{b,Plus@@IntegerDigits[n,b]},{b,2,n}],#[[1]]!=#[[2]]&];

%t Select[Range[0, 1000], Q] (* _Hans Rudolf Widmer_, Oct 08 2022 *)

%o (Sage)

%o n=1000 #change n for more terms

%o S=[]

%o for i in [0..n]:

%o test=False

%o for b in [2..i]:

%o if sum(Integer(i).digits(base=b))==b:

%o test=True

%o break

%o if not test:

%o S.append(i)

%o S

%o # From _Hieronymus Fischer_, Apr 10 2014: (Start)

%o (Smalltalk)

%o A187813NextTerm

%o "Calculates the next term of A187813 greater than the receiver, i.e., calculates a(n+1) from a(n).

%o Usage: a(n) A187813NextTerm

%o Answer: a(n+1)

%o Version 1: Using numOfBasesWithDigitalSumEQBase from A239703 ==> fast calculation, since only the divisors of <an> have to tested to be candidates for bases b with base-b digital sum equal to b"

%o | an |

%o an := self + 1.

%o [an numOfBasesWithDigitalSumEQBase > 0]

%o whileTrue: [an := an+1].

%o ^an

%o -----------

%o A187813NextTerm

%o "Calculates the next term of A187813 greater than the receiver, i.e., calculates a(n+1) from a(n).

%o Usage: a(n) A187813NextTerm

%o Answer: a(n+1)

%o Version 2: Using the equivalence with A008864 and A239708 ==> even much more faster calculation"

%o | p q |

%o self < 0 ifTrue: [^0].

%o self = 0 ifTrue: [^1].

%o self = 1 ifTrue: [^2].

%o p := (self - 1) nextPrime.

%o q := p+1-(2 raisedToInteger: (p+1 integerFloorLog: 2)).

%o [q > 0 and: [(2 raisedToInteger: (q integerFloorLog: 2)) - q = 0]] whileTrue: [p := p nextPrime.

%o q := p + 1 - (2 raisedToInteger: (p + 1 integerFloorLog: 2))].

%o ^p + 1

%o -----------

%o A187813

%o "Calculates the n-th term of A187813, iteratively.

%o Usage: n A187813

%o Answer: a(n)"

%o | an n |

%o n := self.

%o n < 3 ifTrue: [^#(0 1) at: n].

%o an := 2.

%o 4 to: n do: [:i |an := an A187813NextTerm].

%o ^an

%o -----------

%o A187813rec

%o "Calculates the n-th term of A187813, using the recursive method <A187813With: param>

%o Usage: n A187813

%o Answer: a(n)"

%o self < 3 ifTrue: [^#(0 1) at: self].

%o ^self A187813With: self prime

%o -----------

%o A187813With: estimate

%o "Method to calculate the n-th term of A187813 based on the value estimate, recursively. The n-th prime is a adequate estimate. Valid for n > 2.

%o Usage: n A187813With: estimate

%o Answer: a(n)"

%o | x m |

%o (x:=((m:= estimate A239708inv)+self-3) prime + 1) = estimate

%o ifFalse: [^self A187813With: x].

%o (m + 1) A239708 = x

%o ifTrue: [^self A187813With: x + 4].

%o ^x

%o [End]

%Y Cf. A018900, A052224.

%Y Cf. A007953, A079696, A008864, A239708, A000040.

%Y Cf. A239703, A239705.

%K nonn,base

%O 1,3

%A _Tom Edgar_, Aug 30 2013