A032822 Numbers whose set of base-10 digits is {1,4}.
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
Links
- Vincenzo Librandi, Table of n, a(n) for n = 1..1000
- Index entries for 10-automatic sequences.
Crossrefs
Cf. A020452 (primes).
Programs
-
Magma
[n: n in [1..15000] | Set(IntegerToSequence(n, 10)) subset {1, 4}]; // Vincenzo Librandi, May 28 2012
-
Mathematica
Flatten[Table[FromDigits[#,10]&/@Tuples[{1,4},n],{n,5}]] (* 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
-
Python
def A032822(n): return 3*int(bin(n+1)[3:])+(10**((n+1).bit_length()-1)-1)//9 # Chai Wah Wu, Jun 28 2025
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