%I #21 Sep 08 2022 08:44:51
%S 1,4,17,20,65,68,273,276,321,324,1041,1044,1089,1092,4369,4372,4417,
%T 4420,5137,5140,5185,5188,16657,16660,16705,16708,17425,17428,17473,
%U 17476,69905,69908,69953,69956,70673,70676,70721
%N Numbers whose set of base-16 digits is {1,4}.
%H Vincenzo Librandi, <a href="/A032828/b032828.txt">Table of n, a(n) for n = 1..1000</a>
%H <a href="/index/Ar#2-automatic">Index entries for 2-automatic sequences</a>.
%F a(1)=1, a(2)=4; a(n) = 16*a(floor(n/2))+1 for n odd, otherwise a(n) = 16*a(floor((n-1)/2))+4. - _Bruno Berselli_, May 28 2012
%t FromDigits[#,16]&/@Flatten[Table[Tuples[{1,4},n],{n,5}],1] (* _Harvey P. Dale_, Feb 02 2012 *)
%o (Magma) [n: n in [1..75000] | Set(IntegerToSequence(n, 16)) subset {1, 4}]; // _Vincenzo Librandi_, May 28 2012
%o (Maxima) a[1]:1$ a[2]:4$ a[n]:= if oddp(n) then 16*a[floor(n/2)]+1 else 16*a[floor((n-1)/2)]+4$ makelist(a[n],n,1,37); /* _Bruno Berselli_, May 28 2012 */
%o (Python)
%o def a(n): return int(bin(n+1)[3:].replace('1', '4').replace('0', '1'), 16)
%o print([a(n) for n in range(1, 38)]) # _Michael S. Branicky_, Aug 22 2021
%K nonn,base,easy
%O 1,2
%A _Clark Kimberling_
|