login
A032822
Numbers whose set of base-10 digits is {1,4}.
10
1, 4, 11, 14, 41, 44, 111, 114, 141, 144, 411, 414, 441, 444, 1111, 1114, 1141, 1144, 1411, 1414, 1441, 1444, 4111, 4114, 4141, 4144, 4411, 4414, 4441, 4444, 11111, 11114, 11141, 11144, 11411, 11414, 11441, 11444, 14111, 14114
OFFSET
1,2
FORMULA
a(1)=1, a(2)=4; a(n) = 10*a(floor(n/2))+1 for n odd, otherwise a(n) = 10*a(floor((n-1)/2))+4. - Bruno Berselli, May 28 2012
MATHEMATICA
Flatten[Table[FromDigits[#, 10]&/@Tuples[{1, 4}, n], {n, 5}]] (* Vincenzo Librandi, May 28 2012 *)
PROG
(Magma) [n: n in [1..15000] | Set(IntegerToSequence(n, 10)) subset {1, 4}]; // Vincenzo Librandi, May 28 2012
(Maxima) a[1]:1$ a[2]:4$ a[n]:= if oddp(n) then 10*a[floor(n/2)]+1 else 10*a[floor((n-1)/2)]+4$ makelist(a[n], n, 1, 40); /* Bruno Berselli, May 28 2012 */
(Python)
def a(n): return int(bin(n+1)[3:].replace('1', '4').replace('0', '1'))
print([a(n) for n in range(1, 45)]) # Michael S. Branicky, May 13 2021
CROSSREFS
Cf. A020452 (primes).
Sequence in context: A284323 A352403 A091436 * A344258 A288316 A003250
KEYWORD
nonn,base,easy
STATUS
approved