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.

Showing 1-10 of 10 results.

A018900 Sums of two distinct powers of 2.

Original entry on oeis.org

3, 5, 6, 9, 10, 12, 17, 18, 20, 24, 33, 34, 36, 40, 48, 65, 66, 68, 72, 80, 96, 129, 130, 132, 136, 144, 160, 192, 257, 258, 260, 264, 272, 288, 320, 384, 513, 514, 516, 520, 528, 544, 576, 640, 768, 1025, 1026, 1028, 1032, 1040, 1056, 1088, 1152, 1280, 1536, 2049, 2050, 2052, 2056, 2064, 2080, 2112, 2176, 2304, 2560, 3072
Offset: 1

Views

Author

Jonn Dalton (jdalton(AT)vnet.ibm.com), Dec 11 1996

Keywords

Comments

Appears to give all k such that 8 is the highest power of 2 dividing A005148(k). - Benoit Cloitre, Jun 22 2002
Seen as a triangle read by rows, T(n,k) = 2^(k-1) + 2^n, 1 <= k <= n, the sum of the n-th row equals A087323(n). - Reinhard Zumkeller, Jun 24 2009
Numbers whose base-2 sum of digits is 2. - Tom Edgar, Aug 31 2013
All odd terms are A000051. - Robert G. Wilson v, Jan 03 2014
A239708 holds the subsequence of terms m such that m - 1 is prime. - Hieronymus Fischer, Apr 20 2014

Examples

			From _Hieronymus Fischer_, Apr 27 2014: (Start)
a(1) = 3, since 3 = 2^1 + 2^0.
a(5) = 10, since 10 = 2^3 + 2^1.
a(10^2) = 16640
a(10^3) = 35184372089344
a(10^4) = 2788273714550169769618891533295908724670464 = 2.788273714550...*10^42
a(10^5) = 3.6341936214780344527466190...*10^134
a(10^6) = 4.5332938264998904048012398...*10^425
a(10^7) = 1.6074616084721302346802429...*10^1346
a(10^8) = 1.4662184497310967196301632...*10^4257
a(10^9) = 2.3037539289782230932863807...*10^13462
a(10^10) = 9.1836811272250798973464436...*10^42571
(End)
		

Crossrefs

Cf. A000079, A014311, A014312, A014313, A023688, A023689, A023690, A023691 (Hamming weight = 1, 3, 4, ..., 9).
Sum of base-b digits equal b: A226636 (b = 3), A226969 (b = 4), A227062 (b = 5), A227080 (b = 6), A227092 (b = 7), A227095 (b = 8), A227238 (b = 9), A052224 (b = 10). - M. F. Hasler, Dec 23 2016

Programs

  • C
    unsigned hakmem175(unsigned x) {
        unsigned s, o, r;
        s = x & -x; r = x + s;
        o = x ^ r;  o = (o >> 2) / s;
        return r | o;
    }
    unsigned A018900(int n) {
        if (n == 1) return 3;
        return hakmem175(A018900(n - 1));
    } // Peter Luschny, Jan 01 2014
    
  • Haskell
    a018900 n = a018900_list !! (n-1)
    a018900_list = elemIndices 2 a073267_list  -- Reinhard Zumkeller, Mar 07 2012
    
  • Maple
    a:= n-> (i-> 2^i+2^(n-1-i*(i-1)/2))(floor((sqrt(8*n-1)+1)/2)):
    seq(a(n), n=1..100);  # Alois P. Heinz, Feb 01 2022
  • Mathematica
    Select[ Range[ 1056 ], (Count[ IntegerDigits[ #, 2 ], 1 ]==2)& ]
    Union[Total/@Subsets[2^Range[0,10],{2}]] (* Harvey P. Dale, Mar 04 2012 *)
  • PARI
    for(m=1,9,for(n=0,m-1,print1(2^m+2^n", "))) \\ Charles R Greathouse IV, Sep 09 2011
    
  • PARI
    is(n)=hammingweight(n)==2 \\ Charles R Greathouse IV, Mar 03 2014
    
  • PARI
    for(n=0,10^5,if(hammingweight(n)==2,print1(n,", "))); \\ Joerg Arndt, Mar 04 2014
    
  • PARI
    a(n)= my(t=sqrtint(n*8)\/2); 2^t + 2^(n-1-t*(t-1)/2); \\ Ruud H.G. van Tol, Nov 30 2024
    
  • Python
    print([n for n in range(1, 3001) if bin(n)[2:].count("1")==2]) # Indranil Ghosh, Jun 03 2017
    
  • Python
    A018900_list = [2**a+2**b for a in range(1,10) for b in range(a)] # Chai Wah Wu, Jan 24 2021
    
  • Python
    from math import isqrt, comb
    def A018900(n): return (1<<(m:=isqrt(n<<3)+1>>1))+(1<<(n-1-comb(m,2))) # Chai Wah Wu, Oct 30 2024
  • Smalltalk
    distinctPowersOf: b
      "Version 1: Answers the n-th number of the form b^i + b^j, i>j>=0, where n is the receiver.
      b > 1 (b = 2, for this sequence).
      Usage: n distinctPowersOf: 2
      Answer: a(n)"
      | n i j |
      n := self.
      i := (8*n - 1) sqrtTruncated + 1 // 2.
      j := n - (i*(i - 1)/2) - 1.
      ^(b raisedToInteger: i) + (b raisedToInteger: j)
    [by Hieronymus Fischer, Apr 20 2014]
    ------------
    
  • Smalltalk
    distinctPowersOf: b
      "Version 2: Answers an array which holds the first n numbers of the form b^i + b^j, i>j>=0, where n is the receiver. b > 1 (b = 2, for this sequence).
      Usage: n distinctPowersOf: 2
      Answer: #(3 5 6 9 10 12 ...) [first n terms]"
      | k p q terms |
      terms := OrderedCollection new.
      k := 0.
      p := b.
      q := 1.
      [k < self] whileTrue:
             [[q < p and: [k < self]] whileTrue:
                       [k := k + 1.
                       terms add: p + q.
                       q := b * q].
             p := b * p.
             q := 1].
      ^terms as Array
    [by Hieronymus Fischer, Apr 20 2014]
    ------------
    
  • Smalltalk
    floorDistinctPowersOf: b
      "Answers an array which holds all the numbers b^i + b^j < n, i>j>=0, where n is the receiver.
      b > 1 (b = 2, for this sequence).
      Usage: n floorDistinctPowersOf: 2
      Answer: #(3 5 6 9 10 12 ...) [all terms < n]"
      | a n p q terms |
      terms := OrderedCollection new.
      n := self.
      p := b.
      q := 1.
      a := p + q.
      [a < n] whileTrue:
             [[q < p and: [a < n]] whileTrue:
                       [terms add: a.
                       q := b * q.
                       a := p + q].
             p := b * p.
             q := 1.
             a := p + q].
      ^terms as Array
    [by Hieronymus Fischer, Apr 20 2014]
    ------------
    
  • Smalltalk
    invertedDistinctPowersOf: b
      "Given a number m which is a distinct power of b, this method answers the index n such that there are uniquely defined i>j>=0 for which b^i + b^j = m, where m is the receiver;  b > 1 (b = 2, for this sequence).
      Usage: m invertedDistinctPowersOf: 2
      Answer: n such that a(n) = m, or, if no such n exists, min (k | a(k) >= m)"
      | n i j k m |
      m := self.
      i := m integerFloorLog: b.
      j := m - (b raisedToInteger: i) integerFloorLog: b.
      n := i * (i - 1) / 2 + 1 + j.
      ^n
    [by Hieronymus Fischer, Apr 20 2014]
    

Formula

a(n) = 2^trinv(n-1) + 2^((n-1)-((trinv(n-1)*(trinv(n-1)-1))/2)), i.e., 2^A002024(n)+2^A002262(n-1). - Antti Karttunen
a(n) = A059268(n-1) + A140513(n-1). A000120(a(n)) = 2. Complement of A161989. A151774(a(n)) = 1. - Reinhard Zumkeller, Jun 24 2009
A073267(a(n)) = 2. - Reinhard Zumkeller, Mar 07 2012
Start with A000051. If n is in sequence, then so is 2n. - Ralf Stephan, Aug 16 2013
a(n) = A057168(a(n-1)) for n>1 and a(1) = 3. - Marc LeBrun, Jan 01 2014
From Hieronymus Fischer, Apr 20 2014: (Start)
Formulas for a general parameter b according to a(n) = b^i + b^j, i>j>=0; b = 2 for this sequence.
a(n) = b^i + b^j, where i = floor((sqrt(8n - 1) + 1)/2), j = n - 1 - i*(i - 1)/2 [for a Smalltalk implementation see Prog section, method distinctPowersOf: b (2 versions)].
a(A000217(n)) = (b + 1)*b^(n-1) = b^n + b^(n-1).
a(A000217(n)+1) = 1 + b^(n+1).
a(n + 1 + floor((sqrt(8n - 1) + 1)/2)) = b*a(n).
a(n + 1 + floor(log_b(a(n)))) = b*a(n).
a(n + 1) = b^2/(b+1) * a(n) + 1, if n is a triangular number (s. A000217).
a(n + 1) = b*a(n) + (1-b)* b^floor((sqrt(8n - 1) + 1)/2), if n is not a triangular number.
The next term can also be calculated without using the index n. Let m be a term and i = floor(log_b(m)), then:
a(n + 1) = b*m + (1-b)* b^i, if floor(log_b(m/(b+1))) + 1 < i,
a(n + 1) = b^2/(b+1) * m + 1, if floor(log_b(m/(b+1))) + 1 = i.
Partial sum:
Sum_{k=1..n} a(k) = ((((b-1)*(j+1)+i-1)*b^(i-j) + b)*b^j - i)/(b-1), where i = floor((sqrt(8*n - 1) + 1)/2), j = n - 1 - i*(i - 1)/2.
Inverse:
For each sequence term m, the index n such that a(n) = m is determined by n := i*(i-1)/2 + j + 1, where i := floor(log_b(m)), j := floor(log_b(m - b^floor(log_b(m)))) [for a Smalltalk implementation see Prog section, method invertedDistinctPowersOf: b].
Inequalities:
a(n) <= (b+1)/b * b^floor(sqrt(2n)+1/2), equality holds for triangular numbers.
a(n) > b^floor(sqrt(2n)+1/2).
a(n) < b^sqrt(2n)*sqrt(b).
a(n) > b^sqrt(2n)/sqrt(b).
Asymptotic behavior:
lim sup a(n)/b^sqrt(2n) = sqrt(b).
lim inf a(n)/b^sqrt(2n) = 1/sqrt(b).
lim sup a(n)/b^(floor(sqrt(2n))) = b.
lim inf a(n)/b^(floor(sqrt(2n))) = 1.
lim sup a(n)/b^(floor(sqrt(2n)+1/2)) = (b+1)/b.
lim inf a(n)/b^(floor(sqrt(2n)+1/2)) = 1.
(End)
Sum_{n>=1} 1/a(n) = A179951. - Amiram Eldar, Oct 06 2020

Extensions

Edited by M. F. Hasler, Dec 23 2016

A052224 Numbers whose sum of digits is 10.

Original entry on oeis.org

19, 28, 37, 46, 55, 64, 73, 82, 91, 109, 118, 127, 136, 145, 154, 163, 172, 181, 190, 208, 217, 226, 235, 244, 253, 262, 271, 280, 307, 316, 325, 334, 343, 352, 361, 370, 406, 415, 424, 433, 442, 451, 460, 505, 514, 523, 532, 541, 550, 604, 613, 622, 631, 640
Offset: 1

Views

Author

Henry Bottomley, Feb 01 2000

Keywords

Comments

Proper subsequence of A017173. - Rick L. Shepherd, Jan 12 2009
Subsequence of A227793. - Michel Marcus, Sep 23 2013
A007953(a(n)) = 10; number of repdigits = #{55,22222,1^10} = A242627(10) = 3. - Reinhard Zumkeller, Jul 17 2014
a(n) = A094677(n) for n = 1..28. - Reinhard Zumkeller, Nov 08 2015
The number of terms having <= m digits is the coefficient of x^10 in sum(i=0,9,x^i)^m = ((1-x^10)/(1-x))^m. - David A. Corneth, Jun 04 2016
In general, the set of numbers with sum of base-b digits equal to b is a subset of { (b-1)*k + 1; k = 2, 3, 4, ... }. - M. F. Hasler, Dec 23 2016

Crossrefs

Cf. A011557 (1), A052216 (2), A052217 (3), A052218 (4), A052219 (5), A052220 (6), A052221 (7), A052222 (8), A052223 (9), A166311 (11), A235151 (12), A143164 (13), A235225 (14), A235226 (15), A235227 (16), A166370 (17), A235228 (18), A166459 (19), A235229 (20).
Cf. A094677.
Sum of base-b digits equal b: A226636 (b = 3), A226969 (b = 4), A227062 (b = 5), A227080 (b = 6), A227092 (b = 7), A227095 (b = 8), A227238 (b = 9).

Programs

  • Haskell
    a052224 n = a052224_list !! (n-1)
    a052224_list = filter ((== 10) . a007953) [0..]
    -- Reinhard Zumkeller, Jul 17 2014
    
  • Magma
    [n: n in [1..1000] | &+Intseq(n) eq 10 ]; // Vincenzo Librandi, Mar 10 2013
    
  • Maple
    sd := proc (n) options operator, arrow: add(convert(n, base, 10)[j], j = 1 .. nops(convert(n, base, 10))) end proc: a := proc (n) if sd(n) = 10 then n else end if end proc: seq(a(n), n = 1 .. 800); # Emeric Deutsch, Jan 16 2009
  • Mathematica
    Union[Flatten[Table[FromDigits /@ Permutations[PadRight[s, 7]], {s, Rest[IntegerPartitions[10]]}]]] (* T. D. Noe, Mar 08 2013 *)
    Select[Range[1000], Total[IntegerDigits[#]] == 10 &] (* Vincenzo Librandi, Mar 10 2013 *)
  • PARI
    isok(n) = sumdigits(n) == 10; \\ Michel Marcus, Dec 28 2015
    
  • PARI
    \\ This algorithm needs a modified binomial.
    C(n, k)=if(n>=k, binomial(n, k), 0)
    \\ ways to roll s-q with q dice having sides 0 through n - 1.
    b(s, q, n)=if(s<=q*(n-1), s+=q; sum(i=0, q-1, (-1)^i*C(q, i)*C(s-1-n*i, q-1)), 0)
    \\ main algorithm; this program applies to all sequences of the form "Numbers whose sum of digits is m."
    a(n,{m=10}) = {my(q); q = 2; while(b(m, q, 10) < n, q++); q--; s = m; os = m; r=0; while(q, if(b(s, q, 10) < n, n-=b(s, q, 10); s--, r+=(os-s)*10^(q); os = s; q--)); r+= s; r}
    \\ David A. Corneth, Jun 05 2016
    
  • Python
    from sympy.utilities.iterables import multiset_permutations
    def auptodigs(maxdigits, b=10, sod=10): # works for any base, sum-of-digits
        alst = [sod] if 0 <= sod < b else []
        nzdigs = [i for i in range(1, b) if i <= sod]
        nzmultiset = []
        for d in range(1, b):
            nzmultiset += [d]*(sod//d)
        for d in range(2, maxdigits + 1):
            fullmultiset = [0]*(d-1-(sod-1)//(b-1)) + nzmultiset
            for firstdig in nzdigs:
                target_sum, restmultiset = sod - int(firstdig), fullmultiset[:]
                restmultiset.remove(firstdig)
                for p in multiset_permutations(restmultiset, d-1):
                  if sum(p) == target_sum:
                      alst.append(int("".join(map(str, [firstdig]+p)), b))
                      if p[0] == target_sum:
                          break
        return alst
    print(auptodigs(4)) # Michael S. Branicky, Sep 14 2021
    
  • Python
    def A052224(N = 19):
        """Return a generator of the sequence of all integers >= N with the same
        digit sum as N."""
        while True:
            yield N
            N = A228915(N) # skip to next larger integer with the same digit sum
    a = A052224(); [next(a) for  in range(50)] # _M. F. Hasler, Mar 16 2022

Formula

a(n+1) = A228915(a(n)) for any n > 0. - Rémy Sigrist, Jul 10 2018

Extensions

Incorrect formula deleted by N. J. A. Sloane, Jan 15 2009
Extended by Emeric Deutsch, Jan 16 2009
Offset changed by Bruno Berselli, Mar 07 2013

A052217 Numbers whose sum of digits is 3.

Original entry on oeis.org

3, 12, 21, 30, 102, 111, 120, 201, 210, 300, 1002, 1011, 1020, 1101, 1110, 1200, 2001, 2010, 2100, 3000, 10002, 10011, 10020, 10101, 10110, 10200, 11001, 11010, 11100, 12000, 20001, 20010, 20100, 21000, 30000, 100002, 100011, 100020, 100101
Offset: 1

Views

Author

Henry Bottomley, Feb 01 2000

Keywords

Comments

From Joshua S.M. Weiner, Oct 19 2012: (Start)
Sequence is a representation of the "energy states" of "multiplex" notation of 3 quantum of objects in a juggling pattern.
0 = an empty site, or empty hand. 1 = one object resides in the site. 2 = two objects reside in the site. 3 = three objects reside in the site. (See A038447.) (End)
A007953(a(n)) = 3; number of repdigits = #{3,111} = A242627(3) = 2. - Reinhard Zumkeller, Jul 17 2014
Can be seen as a table whose n-th row holds the n-digit terms {10^(n-1) + 10^m + 10^k, 0 <= k <= m < n}, n >= 1. Row lengths are then (1, 3, 6, 10, ...) = n*(n+1)/2 = A000217(n). The first and the n last terms of row n are 10^(n-1) + 2 resp. 2*10^(n-1) + 10^k, 0 <= k < n. - M. F. Hasler, Feb 19 2020

Crossrefs

Cf. A007953, A218043 (subsequence).
Row n=3 of A245062.
Other digit sums: A011557 (1), A052216 (2), A052218 (4), A052219 (5), A052220 (6), A052221 (7), A052222 (8), A052223 (9), A052224 (10), A166311 (11), A235151 (12), A143164 (13), A235225(14), A235226 (15), A235227 (16), A166370 (17), A235228 (18), A166459 (19), A235229 (20).
Other bases: A014311 (binary), A226636 (ternary), A179243 (Zeckendorf).
Cf. A003056, A002262 (triangular coordinates), A056556, A056557, A056558 (tetrahedral coordinates).

Programs

  • Haskell
    a052217 n = a052217_list !! (n-1)
    a052217_list = filter ((== 3) . a007953) [0..]
    -- Reinhard Zumkeller, Jul 17 2014
    
  • Magma
    [n: n in [1..100101] | &+Intseq(n) eq 3 ]; // Vincenzo Librandi, Mar 07 2013
    
  • Mathematica
    Union[FromDigits/@Select[Flatten[Table[Tuples[Range[0,3],n],{n,6}],1],Total[#]==3&]] (* Harvey P. Dale, Oct 20 2012 *)
    Select[Range[10^6], Total[IntegerDigits[#]] == 3 &] (* Vincenzo Librandi, Mar 07 2013 *)
    Union[Flatten[Table[FromDigits /@ Permutations[PadRight[s, 18]], {s, IntegerPartitions[3]}]]] (* T. D. Noe, Mar 08 2013 *)
  • PARI
    isok(n) = sumdigits(n) == 3; \\ Michel Marcus, Dec 28 2015
    
  • PARI
    apply( {A052217_row(n,s,t=-1)=vector(n*(n+1)\2,k,t++>s&&t=!s++;10^(n-1)+10^s+10^t)}, [1..5]) \\ M. F. Hasler, Feb 19 2020
    
  • Python
    from itertools import count, islice
    def agen(): yield from (10**i + 10**j + 10**k for i in count(0) for j in range(i+1) for k in range(j+1))
    print(list(islice(agen(), 40))) # Michael S. Branicky, May 14 2022
    
  • Python
    from math import comb, isqrt
    from sympy import integer_nthroot
    def A052217(n): return 10**((m:=integer_nthroot(6*n,3)[0])-(a:=n<=comb(m+2,3)))+10**((k:=isqrt(b:=(c:=n-comb(m-a+2,3))<<1))-((b<<2)<=(k<<2)*(k+1)+1))+10**(c-1-comb(k+(b>k*(k+1)),2)) # Chai Wah Wu, Dec 11 2024

Formula

T(n,k) = 10^(n-1) + 10^A003056(k) + 10^A002262(k) when read as a table with row lengths n*(n+1)/2, n >= 1, 0 <= k < n*(n+1)/2. - M. F. Hasler, Feb 19 2020
a(n) = 10^A056556(n-1) + 10^A056557(n-1) + 10^A056558(n-1). - Kevin Ryde, Apr 17 2021

Extensions

Offset changed from 0 to 1 by Vincenzo Librandi, Mar 07 2013

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)

A227062 Numbers whose base-5 sum of digits is 5.

Original entry on oeis.org

9, 13, 17, 21, 29, 33, 37, 41, 45, 53, 57, 61, 65, 77, 81, 85, 101, 105, 129, 133, 137, 141, 145, 153, 157, 161, 165, 177, 181, 185, 201, 205, 225, 253, 257, 261, 265, 277, 281, 285, 301, 305, 325, 377, 381, 385, 401, 405, 425, 501, 505, 525, 629, 633, 637
Offset: 1

Views

Author

Tom Edgar, Sep 01 2013

Keywords

Comments

All of the entries are odd.
Subsequence of A016813. - Michel Marcus, Sep 03 2013
In general, the set of numbers with sum of base-b digits equal to b is a subset of { (b-1)*k + 1; k = 2, 3, 4, ... }. - M. F. Hasler, Dec 23 2016

Examples

			The 5-ary expansion of 9 is (1,4), which has sum of digits 5.
The 5-ary expansion of 53 is (2,0,3), which has sum of digits 5.
10 is not on the list since the 5-ary expansion of 10 is (2,0), which has sum of digits 2 not 5.
		

Crossrefs

Cf. A226636 (b = 3), A226969 (b = 4), A227080 (b = 6), A227092 (b = 7), A227095 (b = 8), A227238 (b = 9), A052224 (b = 10).

Programs

  • Mathematica
    Select[Range@ 640, Total@ IntegerDigits[#, 5] == 5 &] (* Michael De Vlieger, Dec 23 2016 *)
  • PARI
    select( is(n)=sumdigits(n,5)==5, [1..999]) \\ M. F. Hasler, Dec 23 2016
    
  • Python
    from sympy.utilities.iterables import multiset_permutations
    def auptodigs(maxdigits_base5):
        alst = []
        for d in range(2, maxdigits_base5 + 1):
            fulldigset = list("0"*(d-2) + "111112234")
            for firstdig in "1234":
                target_sum, restdigset = 5 - int(firstdig), fulldigset[:]
                restdigset.remove(firstdig)
                for p in multiset_permutations(restdigset, d-1):
                    if sum(map(int, p)) == target_sum:
                      alst.append(int(firstdig+"".join(p), 5))
                      if int(p[0]) == target_sum:
                          break
        return alst
    print(auptodigs(5)) # Michael S. Branicky, Sep 13 2021
    
  • Python
    agen = A226636gen(sod=5, base=5) # generator of terms using code in A226636
    print([next(agen) for n in range(1, 56)]) # Michael S. Branicky, Jul 10 2022
  • Sage
    [i for i in [0..1000] if sum(Integer(i).digits(base=5))==5]
    

A227080 Numbers whose base-6 sum of digits is 6.

Original entry on oeis.org

11, 16, 21, 26, 31, 41, 46, 51, 56, 61, 66, 76, 81, 86, 91, 96, 111, 116, 121, 126, 146, 151, 156, 181, 186, 221, 226, 231, 236, 241, 246, 256, 261, 266, 271, 276, 291, 296, 301, 306, 326, 331, 336, 361, 366, 396, 436, 441, 446, 451, 456, 471, 476, 481, 486
Offset: 1

Views

Author

Tom Edgar, Sep 01 2013

Keywords

Comments

Subsequence of A016861. - Michel Marcus, Sep 03 2013
In general, the set of numbers with sum of base-b digits equal to b is a subset of { (b-1)*k + 1; k = 2, 3, 4, ... }. - M. F. Hasler, Dec 23 2016

Examples

			The 6-ary expansion of 11 is (1,5), which has sum of digits 6.
The 6-ary expansion of 46 is (1,1,4), which has sum of digits 6.
9 is not on the list since the 6-ary expansion of 10 is (1,3), which has sum of digits 4 not 6.
		

Crossrefs

Cf. A226636 (b = 3), A226639 (b = 4), A227062 (b = 5), A227080 (b = 6), A227092 (b = 7), A227095 (b = 8), A227238 (b = 9), A052224 (b = 10).

Programs

  • Mathematica
    Select[Range[500],Total[IntegerDigits[#,6]]==6&] (* Harvey P. Dale, Nov 25 2016 *)
  • PARI
    select( is(n)=sumdigits(n,6)==6, [1..999]) \\ M. F. Hasler, Dec 23 2016
    
  • Python
    # see A052224 for a faster version if going to high numbers
    from sympy.ntheory import digits
    def ok(n): return sum(digits(n, 6)[1:]) == 6
    print([k for k in range(487) if ok(k)]) # Michael S. Branicky, Nov 16 2021
    
  • Python
    agen = A226636gen(sod=6, base=6) # generator of terms using code in A226636
    print([next(agen) for n in range(1, 56)]) # Michael S. Branicky, Jul 10 2022
  • Sage
    [i for i in [0..1000] if sum(Integer(i).digits(base=6))==6]
    

A226969 Numbers whose base-4 sum of digits is 4.

Original entry on oeis.org

7, 10, 13, 19, 22, 25, 28, 34, 37, 40, 49, 52, 67, 70, 73, 76, 82, 85, 88, 97, 100, 112, 130, 133, 136, 145, 148, 160, 193, 196, 208, 259, 262, 265, 268, 274, 277, 280, 289, 292, 304, 322, 325, 328, 337, 340, 352, 385, 388, 400, 448, 514, 517, 520, 529, 532
Offset: 1

Views

Author

Tom Edgar, Sep 01 2013

Keywords

Comments

Subsequence of A016777. - Michel Marcus, Sep 03 2013
In general, the set of numbers with sum of base-b digits equal to b is a subset of { (b-1)*k + 1; k = 2, 3, 4, ... }. - M. F. Hasler, Dec 23 2016

Examples

			The quaternary expansion of 13 is (3,1), which has sum of digits 4.
The quaternary expansion of 40 is (2,2,0), which has sum of digits 4.
17 is not on the list since the quaternary expansion of 17 is (1,0,1), which has sum of digits 2 not 4.
		

Crossrefs

Cf. A226636 (b = 3), A227062 (b = 5), A227080 (b = 6), A227092 (b = 7), A227095 (b = 8), A227238 (b = 9), A052224 (b = 10).

Programs

  • Mathematica
    Select[Range@ 540, Total@ IntegerDigits[#, 4] == 4 &] (* Michael De Vlieger, Dec 23 2016 *)
  • PARI
    select( is(n)=sumdigits(n,4)==4, [1..999]) \\ M. F. Hasler, Dec 23 2016
    
  • Python
    agen = A226636gen(sod=4, base=4) # generator of terms using code in A226636
    print([next(agen) for n in range(1, 57)]) # Michael S. Branicky, Jul 10 2022
  • Sage
    [i for i in [0..1000] if sum(Integer(i).digits(base=4))==4]
    

A227092 Numbers whose base-7 sum of digits is 7.

Original entry on oeis.org

13, 19, 25, 31, 37, 43, 55, 61, 67, 73, 79, 85, 91, 103, 109, 115, 121, 127, 133, 151, 157, 163, 169, 175, 199, 205, 211, 217, 247, 253, 259, 295, 301, 349, 355, 361, 367, 373, 379, 385, 397, 403, 409, 415, 421, 427, 445, 451, 457, 463, 469, 493, 499, 505
Offset: 1

Views

Author

Tom Edgar, Sep 01 2013

Keywords

Comments

All of the entries are odd.
Subsequence of A016921. - Michel Marcus, Sep 03 2013
In general, the set of numbers with sum of base-b digits equal to b is a subset of { (b-1)*k + 1; k = 2, 3, 4, ... }. - M. F. Hasler, Dec 23 2016

Examples

			The 7-ary expansion of 13 is (1,6), which has sum of digits 7.
The 7-ary expansion of 103 is (2,0,5), which has sum of digits 7.
10 is not on the list since the 7-ary expansion of 10 is (1,3), which has sum of digits 4 not 7.
		

Crossrefs

Cf. A226636 (b = 3), A226969 (b = 4), A227062 (b = 5), A227080 (b = 6), A227092 (b = 7), A227095 (b = 8), A227238 (b = 9), A052224 (b = 10).

Programs

  • Mathematica
    Select[Range[600],Total[IntegerDigits[#,7]]==7&] (* Harvey P. Dale, Aug 18 2014 *)
  • PARI
    select( is(n)=sumdigits(n,7)==7, [1..999]) \\ M. F. Hasler, Dec 23 2016
    
  • Python
    agen = A226636gen(sod=7, base=7) # generator of terms using code in A226636
    print([next(agen) for n in range(1, 55)]) # Michael S. Branicky, Jul 10 2022
  • Sage
    [i for i in [0..1000] if sum(Integer(i).digits(base=7))==7]
    

A227095 Numbers whose base-8 sum of digits is 8.

Original entry on oeis.org

15, 22, 29, 36, 43, 50, 57, 71, 78, 85, 92, 99, 106, 113, 120, 134, 141, 148, 155, 162, 169, 176, 197, 204, 211, 218, 225, 232, 260, 267, 274, 281, 288, 323, 330, 337, 344, 386, 393, 400, 449, 456, 519, 526, 533, 540, 547, 554, 561, 568, 582, 589, 596, 603
Offset: 1

Views

Author

Tom Edgar, Sep 01 2013

Keywords

Comments

Subsequence of A016993. - Michel Marcus, Sep 03 2013
In general, the set of numbers with sum of base-b digits equal to b is a subset of { (b-1)*k + 1; k = 2, 3, 4, ... }. - M. F. Hasler, Dec 23 2016

Examples

			The 8-ary expansion of 15 is (1,7), which has sum of digits 8.
The 8-ary expansion of 78 is (1,1,6), which has sum of digits 8.
10 is not on the list since the 8-ary expansion of 10 is (1,2), which has sum of digits 3 not 8.
		

Crossrefs

Cf. A226636 (b = 3), A226969 (b = 4), A227062 (b = 5), A227080 (b = 6), A227092 (b = 7), A227095 (b = 8), A227238 (b = 9), A052224 (b = 10).

Programs

  • Mathematica
    Select[Range@ 603, Total@ IntegerDigits[#, 8] == 8 &] (* Michael De Vlieger, Dec 23 2016 *)
  • PARI
    select( is(n)=sumdigits(n,8)==8, [1..999]) \\ M. F. Hasler, Dec 23 2016
    
  • Python
    agen = A226636gen(sod=8, base=8) # generator of terms using code in A226636
    print([next(agen) for n in range(1, 55)]) # Michael S. Branicky, Jul 10 2022
  • Sage
    [i for i in [0..1000] if sum(Integer(i).digits(base=8))==8]
    

A227238 Numbers whose base-9 sum of digits is 9.

Original entry on oeis.org

17, 25, 33, 41, 49, 57, 65, 73, 89, 97, 105, 113, 121, 129, 137, 145, 153, 169, 177, 185, 193, 201, 209, 217, 225, 249, 257, 265, 273, 281, 289, 297, 329, 337, 345, 353, 361, 369, 409, 417, 425, 433, 441, 489, 497, 505, 513, 569, 577, 585, 649, 657, 737, 745
Offset: 1

Views

Author

Tom Edgar, Sep 01 2013

Keywords

Comments

All of the entries are odd.
Subsequence of A017077. - Michel Marcus, Sep 02 2013
In general, the set of numbers with sum of base-b digits equal to b is a subset of { (b-1)*k + 1; k = 2, 3, 4, ... }. - M. F. Hasler, Dec 23 2016

Examples

			The 9-ary expansion of 17 is (1,8), which has sum of digits 9.
The 9-ary expansion of 169 is (2,0,7), which has sum of digits 9.
10 is not on the list since the 9-ary expansion of 10 is (1,1), which has sum of digits 2 not 9.
		

Crossrefs

Cf. A226636 (b = 3), A226969 (b = 4), A227062 (b = 5), A227080 (b = 6), A227092 (b = 7), A227095 (b = 8), A227238 (b = 9), A052224 (b = 10).

Programs

  • Mathematica
    Select[Range@ 750, Total@ IntegerDigits[#, 9] == 9 &] (* Michael De Vlieger, Dec 23 2016 *)
  • PARI
    select( is(n)=sumdigits(n,9)==9, [1..999]) \\ M. F. Hasler, Dec 23 2016
    
  • Python
    agen = A226636gen(sod=9, base=9) # generator of terms using code in A226636
    print([next(agen) for n in range(1, 55)]) # Michael S. Branicky, Jul 10 2022
  • Sage
    [i for i in [0..1000] if sum(Integer(i).digits(base=9))==9]
    
Showing 1-10 of 10 results.