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.

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

Original entry on oeis.org

0, 1, 2, 4, 8, 14, 30, 32, 38, 42, 44, 54, 60, 62, 74, 84, 90, 98, 102, 104, 108, 110, 114, 128, 138, 140, 150, 152, 158, 164, 168, 174, 180, 182, 194, 198, 200, 212, 224, 228, 230, 234, 240, 242, 252, 270, 278, 282, 284, 294, 308, 312, 314, 318, 332, 338, 348
Offset: 1

Views

Author

Tom Edgar, Aug 30 2013

Keywords

Comments

Except for 1, every number is even.
No number ends in 6.
Numbers neither in A018900 nor in A226636 nor in A226969 nor in A227062 nor in A227080 nor ... . - R. J. Mathar, Sep 02 2013
From Hieronymus Fischer, Mar 27 2014, May 09 2014: (Start)
A079696 and this sequence have no terms in common.
Numbers which satisfy m == 1 (mod j) and m > j^2 for any j > 1 are not terms.
Example 1: m = 10^k, k>1, is not a term since 10^k == 1 (mod 9) and 10^k > 9^2.
Example 2: m = 1 + 3k, k > 3, is not a term, since m > 3(1+3) > 3^2.
This is the complement of the disjunction of A079696 with A239708.
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.
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.
(End)

Examples

			8 has binary expansion (1,0,0,0) whose digit sum 1 is not 2,
ternary expansion (2,2) whose digit sum 4 is not 3,
quaternary expansion (2,0) whose digit sum 2 is not 4,
5-ary expansion (1,3) whose digit sum 4 is not 5,
6-ary expansion (1,2) whose digit sum 3 is not 6,
7-ary expansion (1,1) whose digit sum 2 is not 7,
8-ary expansion (1,0) whose digit sum 1 is not 8,
and b-ary expansion (8) when b>8 whose digit sum is 8 not b. Therefore, 8 is in the sequence.
3 has binary expansion (1,1) whose digit sum is 2, so 3 is not in the sequence.
From _Hieronymus Fischer_, Apr 10 2014: (Start)
a(10) = 42 (the 13th prime + 1)
a(100) = 618 (the 113th prime + 1)
a(1000) = 8172 (the 1026th prime + 1)
a(10^4) = 105254 (the 10042nd prime + 1)
a(10^5) = 1300464 (the 100056th prime + 1)
a(10^6) = 15486872 (the 1000063th prime + 1)
a(10^7) = 179425944 (the 10000071st prime + 1)
a(10^8) = 2038076324 (the 10^8 +84th prime + 1)
a(10^9) = 22801765334 (the 10^9 +92nd prime + 1)
a(10^10) = 252097803264 (the 10^10 +102nd prime + 1)
[calculation for large numbers processed with Smalltalk method A187813With: estimate; see Prog section]
(End)
		

Crossrefs

Programs

  • Mathematica
    Q@n_:=AllTrue[Table[{b,Plus@@IntegerDigits[n,b]},{b,2,n}],#[[1]]!=#[[2]]&];
    Select[Range[0, 1000], Q] (* Hans Rudolf Widmer, Oct 08 2022 *)
  • Python
    from itertools import count, islice
    from sympy import isprime
    def A187813_gen(startvalue=0): # generator of terms >= startvalue
        yield from filter(lambda n:n<3 or (isprime(n-1) and n.bit_count()!=2), count(max(startvalue,0)))
    A187813_list = list(islice(A187813_gen(startvalue=20),30)) # Chai Wah Wu, Mar 24 2025
  • Sage
    n=1000 #change n for more terms
    S=[]
    for i in [0..n]:
        test=False
        for b in [2..i]:
            if sum(Integer(i).digits(base=b))==b:
                test=True
                break
        if not test:
            S.append(i)
    S
    # From Hieronymus Fischer, Apr 10 2014: (Start)
    
  • Smalltalk
    A187813NextTerm
      "Calculates the next term of A187813 greater than the receiver, i.e., calculates a(n+1) from a(n).
      Usage: a(n) A187813NextTerm
      Answer: a(n+1)
      Version 1: Using numOfBasesWithDigitalSumEQBase from A239703 ==> fast calculation, since only the divisors of  have to tested to be candidates for bases b with base-b digital sum equal to b"
      | an |
      an := self + 1.
      [an numOfBasesWithDigitalSumEQBase > 0]
      whileTrue: [an := an+1].
      ^an
    -----------
    A187813NextTerm
      "Calculates the next term of A187813 greater than the receiver, i.e., calculates a(n+1) from a(n).
      Usage: a(n) A187813NextTerm
      Answer: a(n+1)
      Version 2: Using the equivalence with A008864 and A239708 ==> even much more faster calculation"
      | p q |
      self < 0 ifTrue: [^0].
      self = 0 ifTrue: [^1].
      self = 1 ifTrue: [^2].
      p := (self - 1) nextPrime.
      q := p+1-(2 raisedToInteger: (p+1 integerFloorLog: 2)).
      [q > 0 and: [(2 raisedToInteger: (q integerFloorLog: 2)) - q = 0]] whileTrue: [p := p nextPrime.
                       q := p + 1 - (2 raisedToInteger: (p + 1 integerFloorLog: 2))].
      ^p + 1
    -----------
    A187813
      "Calculates the n-th term of A187813, iteratively.
      Usage: n A187813
      Answer: a(n)"
      | an n |
      n := self.
      n < 3 ifTrue: [^#(0 1) at: n].
      an := 2.
      4 to: n do: [:i |an := an A187813NextTerm].
      ^an
    -----------
    A187813rec
      "Calculates the n-th term of A187813, using the recursive method <A187813With: param>
      Usage: n A187813
      Answer: a(n)"
      self < 3 ifTrue: [^#(0 1) at: self].
      ^self A187813With: self prime
    -----------
    A187813With: estimate
    "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.
      Usage: n A187813With: estimate
      Answer: a(n)"
      | x m |
      (x:=((m:= estimate A239708inv)+self-3) prime + 1) = estimate
          ifFalse: [^self A187813With: x].
      (m + 1) A239708 = x
          ifTrue: [^self A187813With: x + 4].
      ^x
    [End]
    

Formula

From Hieronymus Fischer, Mar 27 2014: (Start)
A239703(a(n)) = 0.
a(n+1) = min (p > a(n) | A239703(p) = 0)
[for a Smalltalk implementation see Prog section, method A187813NextTerm version 1].
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)))
[for a Smalltalk implementation see Prog section, method A187813NextTerm version 2].
a(n) > Prime(n), for n > 5.
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)).
a(n - m) < Prime(n), for n > 32, where m := i*(i-1)/2 + j - 16 with i and j above.
a(n) = Prime(n + m - 3) + 1, where m = max ( k | A239708(k) < a(n)), n > 3.
Remark: This identity can be used to calculate a(n) recursively. For a Smalltalk implementation see Prog section, methods A187813rec and A187813With: estimate.
With same conditions: a(n) = A008864(n + m - 3).
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.
(End)