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

A053312 a(n) contains n digits (either '1' or '2') and is divisible by 2^n.

Original entry on oeis.org

2, 12, 112, 2112, 22112, 122112, 2122112, 12122112, 212122112, 1212122112, 11212122112, 111212122112, 1111212122112, 11111212122112, 211111212122112, 1211111212122112, 11211111212122112, 111211111212122112, 2111211111212122112, 12111211111212122112
Offset: 1

Views

Author

Henry Bottomley, Mar 06 2000

Keywords

Comments

Corresponding quotients a(n) / 2^n are in A126933. - Bernard Schott, Mar 15 2023

Examples

			a(5) = 22112 since 22112 = 2^5 * 691 and 22112 contains 5 digits.
		

Crossrefs

Programs

  • Maple
    a:= proc(n) option remember; `if`(n=1, 2, (t-> parse(
          cat(`if`(irem(t, 2^n)=0, 2, 1), t)))(a(n-1)))
        end:
    seq(a(n), n=1..20);  # Alois P. Heinz, Feb 02 2025
  • Mathematica
    Select[Flatten[Table[FromDigits/@Tuples[{1,2},n],{n,20}]],Divisible[ #,2^IntegerLength[#]]&] (* Harvey P. Dale, Jul 01 2019 *)
    RecurrenceTable[{a[1]==2, a[n]==a[n-1]+10^(n-1)(2-Mod[a[n-1]/2^(n-1),2])}, a[n], {n, 1, 20}] (* Paul C Abbott, Feb 03 2025 *)
  • Python
    from itertools import count, islice
    def A053312_gen(): # generator of terms
        a = 0
        for n in count(0):
            yield (a:=a+(10**n if (a>>n)&1 else 10**n<<1))
    A053312_list = list(islice(A053312_gen(),20)) # Chai Wah Wu, Mar 15 2023

Formula

a(n) = a(n-1) + 10^(n-1)*(2-[a(n-1)/2^(n-1) mod 2]), i.e., a(n) ends with a(n-1); if the (n-1)-th term is divisible by 2^n then the n-th term begins with a 2; if not, then the n-th term begins with a 1.

A023396 If any odd power of 2 ends with k 1's and 2's, they must be the first k terms of this sequence in reverse order.

Original entry on oeis.org

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

Views

Author

Keywords

Examples

			2^1 ends in 2;
2^5 ends in 32;
2^9 ends in 512;
2^13 ends in 8192;
2^89 ends in ...562112.
There exists a power of two ending in 12, so for n = 3 the choice for a(3) = 1 or a(3) = 2 comes from the existence of a power of two ending in either 112 or 212. As 112 is divisible by 2^n = 8 (and 212 is not) a(3) = 1. - _David A. Corneth_, Jun 11 2020
		

Crossrefs

Programs

  • PARI
    first(n) = my(f = 2, pow10 = 1, pow2 = 2); { for(i = 2, n, pow10*=10; pow2<<=1; c1 = pow10 + f; if(c1 % pow2 == 0, f = c1, c2 = 2*pow10 + f; if(c2 % pow2 == 0, f = c2 ) ) ); Vecrev(digits(f)) } \\ David A. Corneth, Jun 11 2020

Extensions

Definition corrected by Gerry Leversha, Mar 17 2007

A207778 Smallest multiple of 2^n using only 1's and 2's.

Original entry on oeis.org

1, 2, 12, 112, 112, 2112, 2112, 122112, 122112, 12122112, 12122112, 12122112, 111212122112, 1111212122112, 11111212122112, 11111212122112, 11111212122112, 11111212122112, 111211111212122112, 111211111212122112, 111211111212122112, 111211111212122112
Offset: 0

Views

Author

Lekraj Beedassy, Feb 20 2012

Keywords

Comments

An induction-based argument can be used to show that this sequence is actually infinite.
Problem 1, proposed during the 5th All-Soviet-Union Mathematical Competition in 1971 at Riga (Pertsel link), asks for a proof that this sequence is infinite. - Bernard Schott, Mar 20 2023

References

  • J. B. Tabov and P. J. Taylor, Methods of Problem Solving, Book 1, Australian Mathematics Trust, 1996.

Crossrefs

Programs

  • Mathematica
    Table[m = 1; p = 2^k; While[Total@ DigitCount[m p][[3 ;; -1]] > 0, m++]; m p, {k, 0, 11}] (* Michael De Vlieger, Mar 17 2023 *)
  • PARI
    a(n) = my(k=1, d=digits(k*2^n)); while (!((vecmin(d)>=1) && (vecmax(d)<=2)), k++; d=digits(k*2^n)); k*2^n; \\ Michel Marcus, Mar 15 2023

Formula

a(n) <= A053312(n).

Extensions

More terms from Alois P. Heinz, Feb 20 2012

A342932 The unique sequence {a(1), a(2), a(3), a(4), ...} of digits 1, 2, or 3 such that the number a(n)a(n-1)...a(2)a(1), read in base 6, is divisible by 3^n.

Original entry on oeis.org

3, 1, 2, 3, 3, 1, 1, 3, 1, 2, 2, 1, 1, 3, 1, 3, 1, 3, 3, 3, 2, 3, 3, 2, 1, 1, 2, 1, 3, 1, 2, 1, 1, 3, 3, 2, 2, 3, 1, 3, 2, 2, 2, 3, 3, 1, 2, 2, 2, 2, 2, 1, 3, 2, 2, 3, 2, 2, 1, 2, 1, 3, 2, 2, 3, 1, 1, 1, 1, 1, 3, 2, 2, 2, 3, 3, 2, 1, 3, 1, 1, 2, 2, 3, 1, 3, 2, 3, 2, 3, 1, 1, 3, 1, 2, 3, 3, 2, 3, 2, 3, 1, 1, 2, 3
Offset: 1

Views

Author

Eugen Ionascu, Mar 29 2021

Keywords

Comments

The distribution seems to be uniform but random (empirical observation).
To prove that such a digit sequence exists and is unique is a good (but uncommon) example of a proof by induction.

Examples

			3 is divisible by 3^1;
13_6 = 1*6 + 3 = 9, which is divisible by 3^2,
213_6 = 2*6^2 + 1*6 + 3 = 81, which is divisible by 3^3.
		

Crossrefs

Programs

  • Mathematica
    nd[n_] := Module[{k, i, s, ss, L, a}, L = Array[f, n]; f[1] = 3;
      Do[s = Sum[6^(k - 1)*f[k], {k, 1, i - 1}];
       ss = Mod[2^(i - 1)*s/3^(i - 1), 3];
       If[ss == 0, f[i] = 3, If[ss == 1, f[i] = 2, f[i] = 1]], {i, 2, n}];
      s = Sum[6^(k - 1)*f[k], {k, 1, n}];
      {L, s/3^n}]
  • PARI
    { q=0; t=1; for (n=1, 105, print1 (d=[3,1,2][1+lift(-q/Mod(t,3))]", "); q=(t*d+q)/3; t*=2) } \\ Rémy Sigrist, Apr 15 2021
  • Python
    n, div, divnum = 0, 1, 0
    while n < 87:
        div, a = 3*div, 1
        while (a*6**n+divnum)%div != 0:
            a = a+1
        divnum, n = divnum+a*6**n, n+1
        print(a, end=', ') # A.H.M. Smeets, Apr 13 2021
    
Showing 1-4 of 4 results.