OFFSET
1,1
LINKS
Robert Israel, Table of n, a(n) for n = 1..999
FORMULA
a(n) = a(n-1) + 10^(n-1)*(4 - 3*(a(n-1)/2^(n-1) mod 2)), i.e., a(n) ends with a(n-1); if (n-1)-th term is divisible by 2^n then n-th term begins with a 4, if not then n-th term begins with a 1.
MAPLE
A[1]:= 4:
for n from 2 to 100 do
if A[n-1] mod 2^n = 0 then A[n]:= A[n-1]+4*10^(n-1)
else A[n]:= A[n-1]+10^(n-1)
fi
od:
seq(A[i], i=1..100); # Robert Israel, Oct 27 2019
MATHEMATICA
nxt[{n_, a_}]:={n+1, If[Divisible[a, 2^(n+1)], 4*10^IntegerLength[a]+ a, 10^IntegerLength[ a]+a]}; NestList[nxt, {1, 4}, 20][[All, 2]] (* Harvey P. Dale, Oct 30 2022 *)
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Henry Bottomley, Mar 06 2000
EXTENSIONS
Formula corrected by Robert Israel, Oct 27 2019
STATUS
approved