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

A003605 Unique monotonic sequence of nonnegative integers satisfying a(a(n)) = 3n.

Original entry on oeis.org

0, 2, 3, 6, 7, 8, 9, 12, 15, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120
Offset: 0

Views

Author

Keywords

Comments

Another definition: a(0) = 0, a(1) = 2; for n > 1, a(n) is taken to be the smallest positive integer greater than a(n-1) which is consistent with the condition "n is a member of the sequence if and only if a(n) is a multiple of 3". - Benoit Cloitre, Feb 14 2003
Yet another definition: a(0) = 0, a(1)=2; for n > 1, a(n) is the smallest integer > a(n-1) satisfying "if n is in the sequence, a(n)==0 (mod 3)" ("only if" omitted).
This sequence is the case m = 2 of the following family: a(1, m) = m, a(n, m) is the smallest integer > a(n-1, m) satisfying "if n is in the sequence, a(n, m) == 0 (mod (2m-1))". The general formula is: for any k >= 0, for j = -m*(2m-1)^k, ..., -1, 0, 1, ..., m*(2m-1)^k, a((m-1)*(2*m-1)^k+j) = (2*m-1)^(k+1)+m*j+(m-1)*abs(j).
Numbers whose base-3 representation starts with 2 or ends with 0. - Franklin T. Adams-Watters, Jan 17 2006
This sequence was the subject of the 5th problem of the 27th British Mathematical Olympiad in 1992 (see link British Mathematical Olympiad, reference Gardiner's book and second example for the answer to the BMO question). - Bernard Schott, Dec 25 2020

Examples

			9 is in the sequence and the smallest multiple of 3 greater than a(9-1)=a(8)=15 is 18. Hence a(9)=18.
a(1992) = a(2*3^6+534) = 3^7+3*534 = 3789 (answer to B.M.O. problem).
		

References

  • A. Gardiner, The Mathematical Olympiad Handbook: An Introduction to Problem Solving, Oxford University Press, 1997, reprinted 2011, pages 5 and 113-114 (1992).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Unique monotonic sequence of positive integers satisfying a(a(n)) = k*(n-1) + 3: A080637 (k=2), this sequence (k=3), A353651 (k=4), A353652 (k=5), A353653 (k=6).

Programs

  • Maple
    filter:= n ->  (n mod 3 = 0) or (n >= 2*3^floor(log[3](n))):
    select(filter, [$0..1000]); # Robert Israel, Oct 15 2014
  • Mathematica
    a[n_] := a[n] = Which[ Mod[n, 3] == 0, 3 a[n/3], Mod[n, 3] == 1, 2*a[(n-1)/3] + a[(n-1)/3 + 1], True, a[(n-2)/3] + 2*a[(n-2)/3 + 1]]; a[0]=0; a[1]=2; a[2]=3; Table[a[n], {n, 0, 67}] (* Jean-François Alcover, Jul 18 2012, after Michael Somos *)
  • PARI
    a(n)=if(n<3,n+(n>0),(3-(n%3))*a(n\3)+(n%3)*a(n\3+1))
    
  • PARI
    {A(n)=local(d,w,l3=log(3),l2=log(2),l3n);
               l3n = log(n)/l3;
               w   = floor(l3n);         \\ highest exponent w such that 3^w <= n
               d   = frac(l3n)*l3/l2+1;  \\ first digit in base-3 repr. of n
                  if ( d<2 , d=1 , d=2 );\\   make d an integer either 1 or 2
               if(d==1, n = n + 3^w , n = (n - 3^w)*3);
               return(n);}
    \\ Gottfried Helms, Jan 11 2012
    
  • Python
    from sympy import integer_log
    def A003605(n): return max(n+(m:=3**integer_log(n,3)[0]),3*(n-m)) if n else 0  # Chai Wah Wu, Feb 03 2025

Formula

For any k>=0, a(3^k - j) = 2*3^k - 3j, 0 <= j <= 3^(k-1); a(3^k + j) = 2*3^k + j, 0 <= j <= 3^k.
From Michael Somos, May 03 2000: (Start)
a(3*n) = 3*a(n), a(3*n+1) = 2*a(n) + a(n+1), a(3*n+2) = a(n) + 2a(n+1), n > 0.
a(n+1) - 2*a(n) + a(n-1) = {2 if n=3^k, -2 if n=2*3^k, otherwise 0}, n > 1. (End)
a(n) = n + A006166(n). - Vladeta Jovovic, Mar 01 2003
a(n) = abs(2*3^floor(log_3(n)) - n) + 2n - 3^floor(log_3(n)) for n>=1. - Theodore Lamort de Gail, Sep 12 2017
For any k >= 0, a(2*3^k + j) = 3^(k+1) + 3*j, 0 <= j <= 3^k. - Bernard Schott, Dec 25 2020

A007378 a(n), for n >= 2, is smallest positive integer which is consistent with sequence being monotonically increasing and satisfying a(a(n)) = 2n.

Original entry on oeis.org

3, 4, 6, 7, 8, 10, 12, 13, 14, 15, 16, 18, 20, 22, 24, 25, 26, 27, 28, 29, 30, 31, 32, 34, 36, 38, 40, 42, 44, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 97, 98, 99, 100, 101, 102, 103
Offset: 2

Views

Author

Keywords

Comments

This is the unique monotonic sequence {a(n)}, n>=2, satisfying a(a(n)) = 2n.
May also be defined by: a(n), n=2,3,4,..., is smallest positive integer greater than a(n-1) which is consistent with the condition "n is a member of the sequence if and only if a(n) is an even number >= 4". - N. J. A. Sloane, Feb 23 2003
A monotone sequence satisfying a^(k+1)(n) = mn is unique if m=2, k >= 0 or if (k,m) = (1,3). See A088720. - Colin Mallows, Oct 16 2003
Numbers (greater than 2) whose binary representation starts with "11" or ends with "0". - Franklin T. Adams-Watters, Jan 17 2006
Lower density 2/3, upper density 3/4. - Charles R Greathouse IV, Dec 14 2022

References

  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Cf. A003605. Equals A080653 + 2.
This sequence, A079905, A080637 and A080653 are all essentially the same.

Programs

  • Maple
    a := proc(n) option remember; if n < 4 then n+1 else a(iquo(n,2)) + a(iquo(n+1,2)) fi end:
    seq(a(n), n = 2..70); # Peter Bala, Aug 03 2022
  • Mathematica
    max = 70; f[x_] := -x/(1-x) + x/(1-x)^2*(2 + Sum[ x^(2^k + 2^(k+1)) - x^2^(k+1) , {k, 0, Ceiling[Log[2, max]]}]); Drop[ CoefficientList[ Series[f[x], {x, 0, max + 1}], x], 2](* Jean-François Alcover, May 16 2012, from g.f. *)
    a[2]=3; a[3]=4; a[n_?OddQ] := a[n] = a[(n-1)/2+1] + a[(n-1)/2]; a[n_?EvenQ] := a[n] = 2a[n/2]; Table[a[n], {n, 2, 71}] (* Jean-François Alcover, Jun 26 2012, after Vladeta Jovovic *)
  • PARI
    a(n) = my(s=logint(n,2)-1); if(bittest(n,s), n<<1 - 2<Kevin Ryde, Aug 08 2022
  • Python
    from functools import cache
    @cache
    def a(n): return n+1 if n < 4 else a(n//2) + a((n+1)//2)
    print([a(n) for n in range(2, 72)]) # Michael S. Branicky, Aug 04 2022
    

Formula

a(2^i + j) = 3*2^(i-1) + j, 0<=j<2^(i-1); a(3*2^(i-1) + j) = 2^(i+1) + 2*j, 0<=j<2^(i-1).
a(3*2^k + j) = 4*2^k + 3j/2 + |j|/2, k>=0, -2^k <= j < 2^k. - N. J. A. Sloane, Feb 23 2003
a(2*n+1) = a(n+1)+a(n), a(2*n) = 2*a(n). a(n) = n+A060973(n). - Vladeta Jovovic, Mar 01 2003
G.f.: -x/(1-x) + x/(1-x)^2 * (2 + sum(k>=0, t^2(t-1), t=x^2^k)). - Ralf Stephan, Sep 12 2003

Extensions

More terms from Matthew Vandermast and Vladeta Jovovic, Mar 01 2003

A079882 A run of 2^n 1's followed by a run of 2^n 2's, for n=0, 1, 2, ...

Original entry on oeis.org

1, 2, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2
Offset: 0

Views

Author

N. J. A. Sloane, Feb 21 2003

Keywords

Comments

In the sequence of nonnegative integers (cf. A001477) substitute all n by 2^floor(n/2) occurrences of (1 + n mod 2); a(n)=A173920(n+2,3) for n>0. [From Reinhard Zumkeller, Mar 04 2010]

Crossrefs

Partial sums give A079945. Equals 1 + A079944. Cf. A080584.
First differences of A080637.

Programs

  • Maple
    f1 := n->[seq(1,i=1..2^n)]; f2 := n->[seq(2,i=1..2^n)]; s := []; for i from 0 to 10 do s := [op(s), op(f1(i)), op(f2(i))]; od: s;
  • Mathematica
    Table[{PadRight[{},2^n,1],PadRight[{},2^n,2]},{n,0,5}]//Flatten (* Harvey P. Dale, Jul 22 2016 *)

Formula

a(n) = floor(log[2](8*(n+2)/3)) - floor(log[2](n+2)). - Antonio G. Astudillo (afg_astudillo(AT)hotmail.com), Feb 22 2003

A079905 a(1)=1; then a(n) is smallest positive integer which is consistent with sequence being monotonically increasing and satisfying a(a(n)) = 2n+1 for n>1.

Original entry on oeis.org

1, 3, 5, 6, 7, 9, 11, 12, 13, 14, 15, 17, 19, 21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 33, 35, 37, 39, 41, 43, 45, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 96, 97, 98, 99, 100, 101, 102
Offset: 1

Views

Author

N. J. A. Sloane, Feb 21 2003

Keywords

Comments

Alternate definition: a(n) is taken to be smallest positive integer greater than a(n-1) such that the condition "a(a(n)) is always odd" can be satisfied. - Matthew Vandermast, Mar 03 2003
Also: a(n)=smallest positive integer > a(n-1) such that the condition "n is in the sequence if and only if a(n) is even" is false; that is, the condition "either n is not in the sequence and a(n) is odd or n is in the sequence and a(n) is even" is satisfied. - Matthew Vandermast, Mar 05 2003

Crossrefs

See A080637 for a nicer version. Cf. A079000.
Equals A007378(n+1)-1, n>1.
A007378, A079905, A080637, A080653 are all essentially the same sequence.
Union of A079946 and A005408 (the odd numbers).

Programs

Formula

a(1)=1, a(2)=3, then a(3*2^k - 1 + j) = 4*2^k - 1 + 3j/2 + |j|/2 for k >= 1, -2^k <= j < 2^k.
a(n) = 1+A079945(n-1)-A079944(n-1) for n>1, a(1)=1. - Antonio G. Astudillo (afg_astudillo(AT)hotmail.com), Feb 23 2003

Extensions

More terms from Antonio G. Astudillo (afg_astudillo(AT)hotmail.com), Feb 23 2003

A080653 a(1) = 2; for n>1, a(n) is taken to be the smallest integer greater than a(n-1) such that the condition "a(a(n)) is always even" is satisfied.

Original entry on oeis.org

2, 4, 5, 6, 8, 10, 11, 12, 13, 14, 16, 18, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, 32, 34, 36, 38, 40, 42, 44, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 95, 96, 97
Offset: 1

Views

Author

Matthew Vandermast, Mar 01 2003

Keywords

Comments

Also defined by: a(n) = smallest positive number > a(n-1) such that the condition "n is in sequence if and only if a(n) is odd" is false (cf. A079000); that is, the condition "either n is not in the sequence and a(n) is odd or n is in the sequence and a(n) is even" is satisfied.
If prefixed with a(0) = 0, can be defined by: a(n) = smallest nonnegative number > a(n-1) such that the condition "n is in sequence only if a(n) is even" is satisfied.
Lower density 2/3, upper density 3/4. - Charles R Greathouse IV, Dec 14 2022

References

  • Hsien-Kuei Hwang, S Janson, TH Tsai, Exact and asymptotic solutions of the recurrence f(n) = f(floor(n/2)) + f(ceiling(n/2)) + g(n): theory and applications, Preprint, 2016; http://140.109.74.92/hk/wp-content/files/2016/12/aat-hhrr-1.pdf. Also Exact and Asymptotic Solutions of a Divide-and-Conquer Recurrence Dividing at Half: Theory and Applications, ACM Transactions on Algorithms, 13:4 (2017), #47; DOI: 10.1145/3127585

Crossrefs

Equals A007378 - 2.
A007378, A079905, A080637, A080653 are all essentially the same sequence.

Programs

  • Mathematica
    (* b = A007378 *) b[n_] := b[n] = Which[n == 2, 3, n == 3, 4, EvenQ[n], 2 b[n/2], True, b[(n-1)/2+1]+b[(n-1)/2]]; a[1] = 2; a[n_] := b[n+2]-2; Table[a[n], {n, 1, 65}] (* Jean-François Alcover, Oct 05 2016 *)

Formula

a(a(n)) = 2n + 2. - Yifan Xie, Jul 14 2022
a(n+1) - a(n) is in {1, 2}. In particular, n < a(n) <= 2n. More is true: lim inf a(n)/n = 4/3 and lim sup a(n)/n = 3/2. - Charles R Greathouse IV, Dec 14 2022

A353651 Unique monotonic sequence of positive integers satisfying a(a(n)) = k*(n-1) + 3, where k = 4.

Original entry on oeis.org

2, 3, 7, 8, 9, 10, 11, 15, 19, 23, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, 103, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125
Offset: 1

Views

Author

Yifan Xie, May 02 2022

Keywords

Comments

Numbers m such that the base-4 representation of (3*m-1) starts with 11 or 12 or 13 or ends with 0.
First differences give a run of 4^i 1's followed by a run of 4^i 4's, for i = 0, 1, 2, ...

Examples

			a(6) = 10 because (2*4^1 + 1)/3 < 6 <= (5*4^1 + 1)/3, hence a(6) = 6 + 4^1 = 10;
a(9) = 19 because (5*4^1 + 1)/3 < 9 <= (8*4^1 + 1)/3, hence a(9) = 4*(9 - 4^1) - 1 = 19.
		

Crossrefs

For other values of k: A080637 (k=2), A003605 (k=3), this sequence (k=4), A353652 (k=5), A353653 (k=6).

Programs

  • Maple
    isA353651 := proc(n)
        if modp(n,4) = 3 then
            true;
        else
            b4 := convert(3*n-1,base,4) ;
            if op(-1,b4) = 1 and op(-2,b4) <> 0  then
                true ;
            else
                false;
            end if;
        end if;
    end proc:
    for n from 2 to 122 do
        if isA353651(n) then
            printf("%d,",n) ;
        end if;
    end do: # R. J. Mathar, Jul 05 2022
  • PARI
    a(n) = my(n3=3*n, s=logint(n3>>1, 4)<<1); if(n3>>s < 5, n + 1<Kevin Ryde, Apr 15 2022
    (C++)
    /* program used to generate the b-file */
    #include
    using namespace std;
    int main(){
        int cnt1=1, flag=0, cnt2=1, a=2;
        for(int n=1; n<=10000; n++) {
            cout<
    				

Formula

For n in the range (2*4^i + 1)/3 < n <= (5*4^i + 1)/3, for i >= 0:
a(n) = n + 4^i.
a(n) = 1 + a(n-1).
Otherwise, for n in the range (5*4^i + 1)/3 < n <= (8*4^i + 1)/3, for i >= 0:
a(n) = 4*(n - 4^i) - 1.
a(n) = 4 + a(n-1).

A353652 Unique monotonic sequence of positive integers satisfying a(a(n)) = k*(n-1) + 3, where k = 5.

Original entry on oeis.org

2, 3, 8, 9, 10, 11, 12, 13, 18, 23, 28, 33, 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, 63, 68, 73, 78, 83, 88, 93, 98, 103, 108, 113, 118, 123, 128, 133, 138, 143, 148, 153, 158, 163, 168, 173, 178, 183, 188
Offset: 1

Views

Author

Yifan Xie, Jul 15 2022

Keywords

Comments

Numbers m such that the base-5 representation of (2*m-1) starts with 3 or 4 or ends with 0.
First differences give a run of 5^i 1's followed by a run of 5^i 5's, for i >= 0.

Examples

			a(7) = 12 because (5^1 + 1)/2 <= 7 < (3*5^1 + 1)/2, hence a(7) = 7 + 5^1 = 12;
a(11) = 28 because (3*5^1 + 1)/2 <= 11 < (5*5^1 + 1)/2, hence a(11) = 5*(11 - 5^1) - 2 = 28.
		

Crossrefs

For other values of k: A080637 (k=2), A003605 (k=3), A353651 (k=4), this sequence (k=5), A353653 (k=6).

Programs

  • Mathematica
    a[n_] := Module[{n2 = 2n, p}, p = 5^Floor@Log[5, n2]; If[n2 < 3p, n+p, 5(n-p)-2]];
    Table[a[n], {n, 1, 100}] (* Jean-François Alcover, Sep 22 2023, after Kevin Ryde *)
  • PARI
    a(n) = my(n2=n<<1, p=5^logint(n2, 5)); if(n2 < 3*p, n+p, 5*(n-p)-2); \\ Kevin Ryde, Apr 18 2022
    (C++)
    /* program used to generate the b-file */
    #include
    using namespace std;
    int main(){
        int cnt1=1, flag=0, cnt2=1, a=2;
        for(int n=1; n<=10000; n++) {
            cout<
    				

Formula

For n in the range (5^i + 1)/2 <= n < (3*5^i + 1)/2, for i >= 0:
a(n) = n + 5^i.
a(n+1) = 1 + a(n).
Otherwise, for n in the range (3*5^i + 1)/2 < n <= (5*5^i + 1)/2, for i >= 0:
a(n) = 5*(n - 5^i) - 2.
a(n+1) = 5 + a(n).

A353653 Unique monotonic sequence of positive integers satisfying a(a(n)) = k*(n-1) + 3, where k = 6.

Original entry on oeis.org

2, 3, 9, 10, 11, 12, 13, 14, 15, 21, 27, 33, 39, 45, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 93, 99, 105, 111, 117, 123, 129, 135, 141, 147, 153, 159, 165
Offset: 1

Views

Author

Yifan Xie, Jul 15 2022

Keywords

Comments

Numbers m such that the base-6 representation of (5*m-3) starts with 11 or 12 or 13 or 14 or 15 or ends with 0.
First differences give a run of 6^i 1's followed by a run of 6^i 6's, for i >= 0.

Examples

			a(5) = 11 because (2*6^1 + 3)/3 <= 5 < (7*6^1 + 3)/5, hence a(5) = 5 + 6^1 = 11;
a(10) = 21 because (7*6^1 + 3)/5 <= 10 < (12*6^1 + 3)/5, hence a(10) = 6*(10 - 6^1) - 3 = 21.
		

Crossrefs

For other values of k: A080637 (k=2), A003605 (k=3), A353651 (k=4), A353652 (k=5), this sequence (k=6).

Programs

  • Mathematica
    okQ[m_] := With[{id = IntegerDigits[5 m - 3, 6] }, MatchQ[id[[1 ;; 2]], {1, 1}|{1, 2}|{1, 3}|{1, 4}|{1, 5}] || id[[-1]] == 0];
    Join[{2}, Select[Range[3, 1000], okQ]] (* Jean-François Alcover, Sep 22 2023 *)

Formula

For n in the range (2*6^i + 3)/5 <= n < (7*6^i + 3)/5, for i >= 0:
a(n) = n + 6^i.
a(n+1) = 1 + a(n).
Otherwise, for n in the range (7*6^i + 3)/5 <= n < (12*6^i + 3)/5, for i >= 0:
a(n) = 6*(n - 6^i) - 3.
a(n+1) = 6 + a(n).
Showing 1-8 of 8 results.