login
A053312
a(n) contains n digits (either '1' or '2') and is divisible by 2^n.
9
2, 12, 112, 2112, 22112, 122112, 2122112, 12122112, 212122112, 1212122112, 11212122112, 111212122112, 1111212122112, 11111212122112, 211111212122112, 1211111212122112, 11211111212122112, 111211111212122112, 2111211111212122112, 12111211111212122112
OFFSET
1,1
COMMENTS
Corresponding quotients a(n) / 2^n are in A126933. - Bernard Schott, Mar 15 2023
LINKS
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.
EXAMPLE
a(5) = 22112 since 22112 = 2^5 * 691 and 22112 contains 5 digits.
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 *)
PROG
(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
KEYWORD
base,nonn
AUTHOR
Henry Bottomley, Mar 06 2000
STATUS
approved