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-9 of 9 results.

A023758 Numbers of the form 2^i - 2^j with i >= j.

Original entry on oeis.org

0, 1, 2, 3, 4, 6, 7, 8, 12, 14, 15, 16, 24, 28, 30, 31, 32, 48, 56, 60, 62, 63, 64, 96, 112, 120, 124, 126, 127, 128, 192, 224, 240, 248, 252, 254, 255, 256, 384, 448, 480, 496, 504, 508, 510, 511, 512, 768, 896, 960, 992, 1008, 1016, 1020, 1022, 1023
Offset: 1

Views

Author

Keywords

Comments

Numbers whose digits in base 2 are in nonincreasing order.
Might be called "nialpdromes".
Subset of A077436. Proof: Since a(n) is of the form (2^i-1)*2^j, i,j >= 0, a(n)^2 = (2^(2i) - 2^(i+1))*2^(2j) + 2^(2j) where the first sum term has i-1 one bits and its 2j-th bit is zero, while the second sum term switches the 2j-th bit to one, giving i one bits, as in a(n). - Ralf Stephan, Mar 08 2004
Numbers whose binary representation contains no "01". - Benoit Cloitre, May 23 2004
Every polynomial with coefficients equal to 1 for the leading terms and 0 after that, evaluated at 2. For instance a(13) = x^4 + x^3 + x^2 at 2, a(14) = x^4 + x^3 + x^2 + x at 2. - Ben Paul Thurston, Jan 11 2008
From Gary W. Adamson, Jul 18 2008: (Start)
As a triangle by rows starting:
1;
2, 3;
4, 6, 7;
8, 12, 14, 15;
16, 24, 28, 30, 31;
...,
equals A000012 * A130123 * A000012, where A130123 = (1, 0,2; 0,0,4; 0,0,0,8; ...). Row sums of this triangle = A000337 starting (1, 5, 17, 49, 129, ...). (End)
First differences are A057728 = 1; 1; 1; 1; 2,1; 1; 4,2,1; 1; 8,4,2,1; 1; ... i.e., decreasing powers of 2, separated by another "1". - M. F. Hasler, May 06 2009
Apart from first term, numbers that are powers of 2 or the sum of some consecutive powers of 2. - Omar E. Pol, Feb 14 2013
From Andres Cicuttin, Apr 29 2016: (Start)
Numbers that can be digitally generated with twisted ring (Johnson) counters. This is, the binary digits of a(n) correspond to those stored in a shift register where the input bit of the first bit storage element is the inverted output of the last storage element. After starting with all 0’s, each new state is obtained by rotating the stored bits but inverting at each state transition the last bit that goes to the first position (see link).
Examples: for a(n) represented by three bits
Binary
a(5)= 4 -> 100 last bit = 0
a(6)= 6 -> 110 first bit = 1 (inverted last bit of previous number)
a(7)= 7 -> 111
and for a(n) represented by four bits
Binary
a(8) = 8 -> 1000
a(9) = 12 -> 1100 last bit = 0
a(10)= 14 -> 1110 first bit = 1 (inverted last bit of previous number)
a(11)= 15 -> 1111
(End)
Powers of 2 represented in bases which are terms of this sequence must always contain at least one digit which is also a power of 2. This is because 2^i mod (2^i - 2^j) = 2^j, which means the last digit always cycles through powers of 2 (or if i=j+1 then the first digit is a power of 2 and the rest are trailing zeros). The only known non-member of this sequence with this property is 5. - Ely Golden, Sep 05 2017
Numbers k such that k = 2^(1 + A000523(k)) - 2^A007814(k). - Daniel Starodubtsev, Aug 05 2021
A002260(n) = v(a(n)/2^v(a(n))+1) and A002024(n) = A002260(n) + v(a(n)) where v is the dyadic valuation (i.e., A007814). - Lorenzo Sauras Altuzarra, Feb 01 2023

Examples

			a(22) = 64 = 32 + 32 = 2^5 + a(16) = 2^A003056(20) + a(22-5-1).
a(23) = 96 = 64 + 32 = 2^6 + a(16) = 2^A003056(21) + a(23-6-1).
a(24) = 112 = 64 + 48 = 2^6 + a(17) = 2^A003056(22) + a(24-6-1).
		

Crossrefs

A000337(r) = sum of row T(r, c) with 0 <= c < r. See also A002024, A003056, A140129, A140130, A221975.
Cf. A007088, A130123, A101082 (complement), A340375 (characteristic function).
This is the base-2 version of A064222. First differences are A057728.
Subsequence of A077436, of A129523, of A277704, and of A333762.
Subsequences: A043569 (nonzero even terms, or equally, nonzero terms doubled), A175332, A272615, A335431, A000396 (its even terms only), A324200.
Positions of zeros in A049502, A265397, A277899, A284264.
Positions of ones in A283983, A283989.
Positions of nonzero terms in A341509 (apart from the initial zero).
Positions of squarefree terms in A260443.
Fixed points of A264977, A277711, A283165, A334666.
Distinct terms in A340632.
Cf. also A309758, A309759, A309761 (for analogous sequences).

Programs

  • Haskell
    import Data.Set (singleton, deleteFindMin, insert)
    a023758 n = a023758_list !! (n-1)
    a023758_list = 0 : f (singleton 1) where
    f s = x : f (if even x then insert z s' else insert z $ insert (z+1) s')
    where z = 2*x; (x, s') = deleteFindMin s
    -- Reinhard Zumkeller, Sep 24 2014, Dec 19 2012
    
  • Maple
    a:=proc(n) local n2,d: n2:=convert(n,base,2): d:={seq(n2[j]-n2[j-1],j=2..nops(n2))}: if n=0 then 0 elif n=1 then 1 elif d={0,1} or d={0} or d={1} then n else fi end: seq(a(n),n=0..2100); # Emeric Deutsch, Apr 22 2006
  • Mathematica
    Union[Flatten[Table[2^i - 2^j, {i, 0, 100}, {j, 0, i}]]] (* T. D. Noe, Mar 15 2011 *)
    Select[Range[0, 2^10], NoneTrue[Differences@ IntegerDigits[#, 2], # > 0 &] &] (* Michael De Vlieger, Sep 05 2017 *)
  • PARI
    for(n=0,2500,if(prod(k=1,length(binary(n))-1,component(binary(n),k)+1-component(binary(n),k+1))>0,print1(n,",")))
    
  • PARI
    A023758(n)= my(r=round(sqrt(2*n--))); (1<<(n-r*(r-1)/2)-1)<<(r*(r+1)/2-n)
    /* or, to illustrate the "decreasing digit" property and analogy to A064222: */
    A023758(n,show=0)={ my(a=0); while(n--, show & print1(a","); a=vecsort(binary(a+1)); a*=vector(#a,j,2^(j-1))~); a} \\ M. F. Hasler, May 06 2009
    
  • PARI
    is(n)=if(n<5,1,n>>=valuation(n,2);n++;n>>valuation(n,2)==1) \\ Charles R Greathouse IV, Jan 04 2016
    
  • PARI
    list(lim)=my(v=List([0]),t); for(i=1,logint(lim\1+1,2), t=2^i-1; while(t<=lim, listput(v,t); t*=2)); Set(v) \\ Charles R Greathouse IV, May 03 2016
    
  • Python
    def a_next(a_n): return (a_n | (a_n >> 1)) + (a_n & 1)
    a_n = 1; a = [0]
    for i in range(55): a.append(a_n); a_n = a_next(a_n) # Falk Hüffner, Feb 19 2022
    
  • Python
    from math import isqrt
    def A023758(n): return (1<<(m:=isqrt(n-1<<3)+1>>1))-(1<<(m*(m+1)-(n-1<<1)>>1)) # Chai Wah Wu, Feb 23 2025

Formula

a(n) = 2^s(n) - 2^((s(n)^2 + s(n) - 2n)/2) where s(n) = ceiling((-1 + sqrt(1+8n))/2). - Sam Alexander, Jan 08 2005
a(n) = 2^k + a(n-k-1) for 1 < n and k = A003056(n-2). The rows of T(r, c) = 2^r-2^c for 0 <= c < r read from right to left produce this sequence: 1; 2, 3; 4, 6, 7; 8, 12, 14, 15; ... - Frank Ellermann, Dec 06 2001
For n > 0, a(n) mod 2 = A010054(n). - Benoit Cloitre, May 23 2004
A140130(a(n)) = 1 and for n > 1: A140129(a(n)) = A002262(n-2). - Reinhard Zumkeller, May 14 2008
a(n+1) = (2^(n - r(r-1)/2) - 1) 2^(r(r+1)/2 - n), where r=round(sqrt(2n)). - M. F. Hasler, May 06 2009
Start with A000225. If k is in the sequence, then so is 2k. - Ralf Stephan, Aug 16 2013
G.f.: (x^2/((2-x)*(1-x)))*(1 + Sum_{k>=0} x^((k^2+k)/2)*(1 + x*(2^k-1))). The sum is related to Jacobi theta functions. - Robert Israel, Feb 24 2015
A049502(a(n)) = 0. - Reinhard Zumkeller, Jun 17 2015
a(n) = a(n-1) + a(n-d)/a(d*(d+1)/2 + 2) if n > 1, d > 0, where d = A002262(n-2). - Yuchun Ji, May 11 2020
A277699(a(n)) = a(n)^2, A306441(a(n)) = a(n+1). - Antti Karttunen, Feb 15 2021 (the latter identity from A306441)
Sum_{n>=2} 1/a(n) = A211705. - Amiram Eldar, Feb 20 2022

Extensions

Definition changed by N. J. A. Sloane, Jan 05 2008

A062289 Numbers n such that n-th row in Pascal triangle contains an even number, i.e., A048967(n) > 0.

Original entry on oeis.org

2, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77
Offset: 1

Views

Author

Ahmed Fares (ahmedfares(AT)my-deja.com), Jul 02 2001

Keywords

Comments

Numbers n such that binary representation contains the bit string "10". Union of A043569 and A101082. - Rick L. Shepherd, Nov 29 2004
The asymptotic density of this sequence is 1 (Burns, 2016). - Amiram Eldar, Jan 26 2021

Crossrefs

Complement of A000225, so these might be called non-Mersenne numbers.
A132782 is a subsequence.

Programs

  • Haskell
    a062289 n = a062289_list !! (n-1)
    a062289_list = 2 : g 2 where
       g n = nM n : g (n+1)
       nM k = maximum $ map (\i -> i + min i (a062289 $ k-i+1)) [2..k]
       -- Cf. link [Oliver Kullmann, Xishun Zhao], Def. 3.1, page 3.
    -- Reinhard Zumkeller, Feb 21 2012, Dec 31 2010
    
  • Mathematica
    ok[n_] := MatchQ[ IntegerDigits[n, 2], {_, 1, 0, _}]; Select[ Range[100], ok] (* Jean-François Alcover, Dec 12 2011, after Rick L. Shepherd *)
  • PARI
    isok(m) = #select(x->((x%2)==0), vector(m+1, k, binomial(m, k-1))); \\ Michel Marcus, Jan 26 2021
    
  • Python
    def A062289(n): return n+(m:=n.bit_length())-(not n>=(1<Chai Wah Wu, Jun 30 2024

Formula

a(n) = A057716(n+1) - 1.
a(n) = 2 if n=1, otherwise max{min{2*i, a(n-i+1) + i}: 1 < i <= n}.
A036987(a(n)) = 0. - Reinhard Zumkeller, Mar 06 2012
A007461(a(n)) mod 2 = 0. - Reinhard Zumkeller, Apr 02 2012
A102370(n) = A105027(a(n)). - Reinhard Zumkeller, Jul 21 2012
A261461(a(n)) = A261922(a(n)). - Reinhard Zumkeller, Sep 17 2015

Extensions

More terms from Rick L. Shepherd, Nov 29 2004

A101082 Numbers n such that binary representation contains bit strings "10" and "01" (possibly overlapping).

Original entry on oeis.org

5, 9, 10, 11, 13, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 29, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 61, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92
Offset: 1

Views

Author

Rick L. Shepherd, Nov 29 2004

Keywords

Comments

Subsequence of A062289; set difference A062289 minus A043569.
Complement of A023758. Also numbers not the sum of consecutive powers of 2. - Omar E. Pol, Mar 04 2013
Equivalently, numbers not the difference of two powers of two. - Charles R Greathouse IV, Mar 07 2013
The terms >=9 are bases in which a power of 2 exists, which does not contain a digit that is a power of 2. In base 10, 2^16 = 65536 is such a number, as it does not contain any one-digit power of 2, which in base 10 are 1, 2, 4 and 8. - Patrick Wienhöft, Jul 28 2016

Examples

			29 = 11101_2 is a term, "10" and "01" are contained (here overlapping).
		

Crossrefs

Complement: A023758.

Programs

  • Haskell
    a101082 n = a101082_list !! (n-1)
    a101082_list = filter ((> 0) . a049502) [0..]
    -- Reinhard Zumkeller, Jun 17 2015
    
  • Mathematica
    Select[Range@ 120, Function[d, Times @@ Total@ Map[Map[Function[k, Boole@ MatchQ[#, k]], {{1, 0}, {0, 1}}] &, Partition[d, 2, 1]] > 0]@ IntegerDigits[#, 2] &] (* Michael De Vlieger, Dec 23 2016 *)
    Select[Range[100],With[{c=IntegerDigits[#,2]},SequenceCount[c,{1,0}]>0&&SequenceCount[c,{0,1}]>0]&] (* Harvey P. Dale, Jun 08 2025 *)
  • PARI
    is(n)=n>>=valuation(n,2);n+1!=1<Charles R Greathouse IV, Mar 07 2013
    
  • Python
    def A101082(n):
        def f(x): return n+((k:=x.bit_length())*(k-1)>>1)+sum(1 for i in range(k) if (1<Chai Wah Wu, Feb 23 2025

Formula

a(n) ~ n. In particular a(n) = n + (log_2 n)^2/2 + O(log n). - Charles R Greathouse IV, Mar 07 2013
A049502(a(n)) > 0. - Reinhard Zumkeller, Jun 17 2015

A276349 Numbers consisting of a nonempty string of 1's followed by a nonempty string of 0's.

Original entry on oeis.org

10, 100, 110, 1000, 1100, 1110, 10000, 11000, 11100, 11110, 100000, 110000, 111000, 111100, 111110, 1000000, 1100000, 1110000, 1111000, 1111100, 1111110, 10000000, 11000000, 11100000, 11110000, 11111000, 11111100, 11111110, 100000000, 110000000, 111000000
Offset: 1

Views

Author

Jaroslav Krizek, Aug 30 2016

Keywords

Comments

Intersection of A037415 and A009996 except for 1 [Corrected by David A. Corneth, Aug 30 2016].
Set of terms from sequence A052983.
a(n) is the binary expansion of A043569(n). - Michel Marcus, Sep 04 2016

Examples

			60 is of the form binomial(a, 2) + b where 0 < b <= a and a = 11, b = 5. So a(60) has (11 + 1) digits and 5 leading ones. The other digits are 0. Giving a(60) = 111110000000. It has 7 (more than 1) trailing zeros so the next one, a(61) is a(60) + 10^(7 - 1). - _David A. Corneth_, Aug 30 2016
		

Crossrefs

Programs

  • Magma
    [n: n in [1..10^7] | Seqint(Setseq(Set(Sort(Intseq(n))))) eq 10 and Seqint(Sort((Intseq(n)))) eq n];
    
  • Maple
    seq(seq(10^(m+1)*(1-10^(-j))/9,j=1..m),m=1..20); # Robert Israel, Sep 02 2016
  • Mathematica
    Table[FromDigits@ Join[ConstantArray[1, #1], ConstantArray[0, #2]] & @@@ Transpose@ {#, n - #} &@ Range[n - 1], {n, 2, 9}] // Flatten (* Michael De Vlieger, Aug 30 2016 *)
    Flatten[Table[FromDigits[Join[PadRight[{},n,1],PadRight[{},k,0]]],{n,8},{k,8}]]//Sort (* Harvey P. Dale, Jan 09 2019 *)
  • PARI
    is(n) = vecmin(digits(n))==0 && vecmax(digits(n))==1 && digits(n)==vecsort(digits(n), , 4) \\ Felix Fröhlich, Aug 30 2016
    
  • PARI
    a(n) = my(r =  ceil((sqrt(1+8*n)+1)/2), k = n - binomial(r-1, 2));10^(r-k)*(10^(k)-1)/9
    \\ given an element n, computes the next element of the sequence.
    nxt(n) = my(d = digits(n), qd=#d, s = vecsum(d)); if(qd-s>1, n+10^(qd-s-1), 10^qd)
    \\ given an element n of the sequence, computes its place in the sequence.
    inv(n) = my(d = digits(n)); binomial(#d-1,2) + vecsum(d) \\ David A. Corneth, Aug 31 2016
    
  • Python
    from math import isqrt, comb
    def A276349(n): return 10*(10**(m:=isqrt(n<<3)+1>>1)-10**(comb(m+1,2)-n))//9 # Chai Wah Wu, Jun 16 2025

Formula

A227362(a(n)) = 10.
From Robert Israel, Sep 02 2016: (Start)
a((m^2-m)/2+j) = 10^(m+1)*(1-10^(-j))/9 for m>=1, 1<=j<=m.
a(n) = 10*(10^m - 10^(-n+m*(m+1)/2))/9 where m = A002024(n). (End)
A002275(A002260(n)) * 10^A004736(n) - Peter Kagey, Sep 02 2016
Sum_{n>=1} 1/a(n) = A073668. - Amiram Eldar, Feb 20 2022
a(n) = 10*A309761(n). - Chai Wah Wu, Jun 16 2025

A341694 Square array T(n, k) read by antidiagonals upwards, n, k > 0: T(n, k) = A227736(n, k) for k = 1..A005811(n), and T(n, k) = T(n, k - A005811(n)) + ... + T(n, k-1) for k > A005811(n).

Original entry on oeis.org

1, 1, 1, 2, 1, 1, 2, 2, 2, 1, 1, 1, 2, 3, 1, 1, 1, 3, 2, 5, 1, 3, 2, 1, 4, 2, 8, 1, 3, 3, 3, 3, 7, 2, 13, 1, 1, 1, 3, 5, 5, 11, 2, 21, 1, 1, 2, 4, 3, 8, 9, 18, 2, 34, 1, 2, 1, 1, 5, 3, 13, 17, 29, 2, 55, 1, 2, 1, 1, 4, 9, 3, 21, 31, 47, 2, 89, 1
Offset: 1

Views

Author

Rémy Sigrist, Feb 17 2021

Keywords

Comments

This table contains all Fibonacci sequences of order m > 0 with positive terms:
- order 1 corresponds to constant sequences (n in A126646),
- order 2 corresponds to Fibonacci-like sequences (n in A043569),
- order 3 corresponds to tribonacci-like sequences (n in A043570),
- order 4 corresponds to tetranacci-like sequences (n in A043571).
For any n > 0, the row A341746(n) corresponds to the n-th row from which the first term has been removed.

Examples

			Array T(n, k) begins:
  n\k|  1  2  3  4  5   6   7   8   9   10   11   12   13    14
  ---+---------------------------------------------------------
    1|  1  1  1  1  1   1   1   1   1    1    1    1    1     1 --> A000012
    2|  1  1  2  3  5   8  13  21  34   55   89  144  233   377 --> A000045
    3|  2  2  2  2  2   2   2   2   2    2    2    2    2     2 --> A007395
    4|  2  1  3  4  7  11  18  29  47   76  123  199  322   521 --> A000032
    5|  1  1  1  3  5   9  17  31  57  105  193  355  653  1201 --> A000213
    6|  1  2  3  5  8  13  21  34  55   89  144  233  377   610 --> A000045
    7|  3  3  3  3  3   3   3   3   3    3    3    3    3     3 --> A010701
    8|  3  1  4  5  9  14  23  37  60   97  157  254  411   665 --> A104449
    9|  1  2  1  4  7  12  23  42  77  142  261  480  883  1624 --> A275778
   10|  1  1  1  1  4   7  13  25  49   94  181  349  673  1297 --> A000288
		

Crossrefs

Programs

  • PARI
    See Links section.

Formula

T(A341746(n), k) = T(n, k+1).
T(n, 1) = A136480(n).

A118586 Numbers whose binary expansion contains group of at least two 1's followed by a nonempty group of 0's.

Original entry on oeis.org

6, 12, 14, 24, 28, 30, 48, 56, 60, 62, 96, 112, 120, 124, 126, 192, 224, 240, 248, 252, 254, 384, 448, 480, 496, 504, 508, 510, 768, 896, 960, 992, 1008, 1016, 1020, 1022, 1536, 1792, 1920, 1984, 2016, 2032, 2040, 2044, 2046, 3072, 3584, 3840, 3968, 4032
Offset: 1

Views

Author

Zak Seidov, May 07 2006

Keywords

Comments

All terms are even.

Examples

			4080_10 = 111111110000_2.
		

Crossrefs

Programs

  • Mathematica
    Sort[Flatten[Table[Sum[2^k,{k,k1,k2}],{k1,1,10},{k2,k1+1,11}]]]
  • Python
    from itertools import count, islice
    def agen(): # generator of terms
        for d in count(3):
            for i in range(2, d):
                yield int("1"*i + "0"*(d-i), 2)
    print(list(islice(agen(), 50))) # Michael S. Branicky, Feb 20 2022

Formula

Sum_{n>=1} 1/a(n) = -1 + A065442. - Amiram Eldar, Feb 20 2022

A231387 a(n) is a prime number that cannot be the center term of a length 3 arithmetic progression prime group with a common difference whose number of runs in binary expansion is 2.

Original entry on oeis.org

2, 3, 199, 1319, 2371, 2437, 3253, 6871, 6991, 7937, 7951, 9041, 9973, 10631, 11941, 12379, 12671, 13009, 13147, 13187, 13267, 13799, 13859, 14479, 16889, 17519, 20051, 21089, 26003, 27281, 27529, 29581, 31477, 32009, 34439, 38561, 41611, 42719, 43543, 44839
Offset: 1

Views

Author

Lei Zhou, Nov 08 2013

Keywords

Comments

Fewer than 0.7% of the first three million primes have this property.
AP-3 is defined as 3 prime groups in arithmetic progression.
Hypothesized property: for n>=3, there exists at least one number k whose number of runs in binary expansion (A005811) equals 4, such that {a(n)-k, a(n), a(n)+k} forms an AP-3 group.

Examples

			2 and 3 cannot be the second term of an AP-3 prime group, so a(1)=2 and a(2)=3;
For any prime numbers between 5 and 197, there exists at least one number k in A043569 such that {a-k, a, a+k} forms an AP-3 prime group.  For example, when p=197, there are the following groups {5,197,389}, {101,197,293}, {137,197,257}, and {167,197,227} with corresponding k = 192 = 11000000 base 2 = A043569(23), 96 = 1100000 base 2 = A043569(17), 60 = 111100 base 2 = A043569(14), and 30 = 11110 base 2 = A043569(10).
However, when p = 199, among all six AP-3 groups, {19,199,379}, {31,199,367}, {61,199,337}, {67,199,331}, {127,199,271}, and {157,199,241}, none of k value (180 = 10110100 base 2, 168 = 10101000 base 2, 138 = 10001010 base 2, 132 = 10000100 base 2, 72 = 1001000, and 42 = 101010 respectively) is a term of A043569. None of them is in the form of 1..10..0 base 2 thus not an element of A043569.
So a(3)=199.
		

Crossrefs

Programs

  • Mathematica
    seed = 1; Table[While[seed = NextPrime[seed]; sum = seed*2; lowbond = sum; cp1 = seed; While[cp1 = NextPrime[cp1]; (lowbond > 2) && (cp1 < sum), cp2 = sum - cp1; If[PrimeQ[cp2], test = cp2 - cp1; rank = Length[Length /@ Split[IntegerDigits[test, 2]]]; lowbond = Min[rank, lowbond]]]; lowbond == 2]; seed, {i, 1, 41}]

A370698 Rectangular array, read by antidiagonals: row n consists of the numbers m whose binary representation has exactly n runs.

Original entry on oeis.org

1, 3, 2, 7, 4, 5, 15, 6, 9, 10, 31, 8, 11, 18, 21, 63, 12, 13, 20, 37, 42, 127, 14, 17, 22, 41, 74, 85, 255, 16, 19, 26, 43, 82, 149, 170, 511, 24, 23, 34, 45, 84, 165, 298, 341, 1023, 28, 25, 36, 53, 86, 169, 330, 597, 682, 2047, 30, 27, 38, 69, 90, 171
Offset: 1

Views

Author

Clark Kimberling, Mar 11 2024

Keywords

Comments

Every positive integer occurs exactly once, and for every n, the numbers in row n have the parity of n.

Examples

			Corner:
    1    3    7   15   31   63  127  255
    2    4    6    8   12   14   16   24
    5    9   11   13   17   19   23   25
   10   18   20   22   26   34   36   38
   21   37   41   43   45   53   69   73
   42   74   82   84   86   90  106  138
   85  149  165  169  171  173  181  213
  170  298  330  338  340  342  346  362
  341  597  661  677  681  683  685  693
The binary representation of 22 is 10110, which has 4 runs: 1, 0, 11, 0.
		

Crossrefs

Cf. A007089, A005811 (# runs in binary n), A000225 (row 1), A043569 (row 2), A043570 (row 3), A000975 (column 1), A370893 (ternary).

Programs

  • Mathematica
    a[n_] := a[n] = Select[Range[8000], Length[Split[IntegerDigits[#, 2]]] == n &];
    t[n_, k_] := a[n][[k]];
    Grid[Table[t[n, k], {n, 1, 12}, {k, 1, 12}]] (* array *)
    Table[t[n - k + 1, k], {n, 12}, {k, n, 1, -1}] // Flatten (* sequence *)

A383038 Positive integers which can be expressed in the form b^r - b^s where b, r, and s are positive integers.

Original entry on oeis.org

2, 4, 6, 8, 12, 14, 16, 18, 20, 24, 28, 30, 32, 42, 48, 54, 56, 60, 62, 64, 72, 78, 90, 96, 100, 110, 112, 120, 124, 126, 128, 132, 156, 162, 180, 182, 192, 210, 216, 224, 234, 240, 248, 252, 254, 256, 272, 294, 306, 336, 342, 380, 384, 420, 448, 462, 480, 486, 496, 500
Offset: 1

Views

Author

Boas Bakker, Apr 13 2025

Keywords

Comments

Terms are all even because b^r - b^s == b - b == 0 (mod 2).
From David A. Corneth, Apr 26 2025: (Start)
By definition, b, s, r and b^r - b^s is positive. Therefore, r > s. If b = 1 then b^r - b^s = 1^r - 1^s = 0 which is excluded by default so b > 1. Suppose we look for terms <= U. Then b is maximal when (s, r) = (1, 2) i.e. b^2 - b <= U. Solving for b gives (sqrt(4*U + 1) + 1) / 2.
As r > s >= 1, r >= 2.
Once b is fixed, b^r - b^s is minimal when s = r-1, enabling the largest r.
So we'd have b^r - b^(r-1) = (b - 1)*(b^(r-1)) <= U. Solving for r gives r <= log(U / (b - 1)) / log(b) + 1.
Once b and r are fixed we have
b^r - b^s <= U so b^r - U <= b^s. Solving for s gives log(b^r - U) / log(b) <= s.
Summarizing we have
2 <= b <= (sqrt(4*U + 1) + 1) / 2,
2 <= r <= log(U / (b - 1)) / log(b) + 1,
log(b^r - U) / log(b) <= s <= r-1. (End)

Examples

			a(6) = 14 = 16 - 2 = 2^4 - 2^1.
a(9) = 20 = 25 - 5 = 5^2 - 5^1.
As _David A. Corneth_ said, we know r > s > 0 and b > 1, so r > 1, and the smallest value of b is 2. So b^r - b^s >= b^(r-1) >= 2^(r-1). So to prove 10 is not in the sequence, we only need to check up up to r=4, because for r=5, 2^(s-1) = 2^4 = 16 > 10. This means there are 6 combinations of (r, s) we need to check. We also know b^r - b^s == 0 (mod b) because s > 0, so we only need to check divisors of 10. So with b = 2 and s < r < 5, we get the terms {2, 4, 6, 8, 12, 14}. With b=5 the smallest term is 5^2 - 5^1 = 20, which is bigger than 10. For b>5, b^r - b^s >= b^2 - b > 5^2 - 5, so we don't need to check those values of b.
		

Crossrefs

The terms of the case b=2 are in A043569.

Programs

  • Julia
    function A383038List(limit::Int)
        res = Set{Int}()
        for b in 2:floor(Int, sqrt(limit)) + 2
            for r in 2:limit
                valr = b^(r-1) * (b-1)
                valr > limit && break
                br = b^r
                for s in 1:r-1
                    val = br - b^s
                    val > 0 && val <= limit && push!(res, val)
        end end end
        sort(collect(res)) end
    println(A383038List(500))  # Peter Luschny, Aug 17 2025
  • PARI
    upto(n) = {n++; my(res = List());
        maxb = ceil((sqrtint(4*n + 1) + 1) / 2);
        for(b = 2, maxb,
            maxr = logint(n\(b-1), b) + 1;
            for(r = 2, maxr,
                mins = max(1, ceil(log(max(b^r - n, 1)) / log(b)));
                mins = min(mins, r-1); \\ min() to fix messed up rounding when b^r - n is a power of b. Also solved by increasing n by 1 initially (n++).
                forstep(s = r-1, mins, -1,
                    c = b^r - b^s;
                    listput(res, c);
                );
            );
        );
        Set(res)
    } \\ David A. Corneth, Apr 26 2025
    
  • Python
    from sympy import integer_nthroot
    aupto = 500
    b_max, A383038 = (i := integer_nthroot(aupto,2))[0] + 2 - i[1], set()
    for b in range(2, b_max):
        r, s = 2, 1
        while (br:=b**r) - b**s <= aupto:
            while s > 0 and (res := br - b**s) <= aupto: A383038.add(res); s -= 1
            r += 1
            s = r - 1
    print(sorted(A383038)) # Karl-Heinz Hofmann, Apr 29 2025
    
Showing 1-9 of 9 results.