A031997 Odd numbers which when cubed give number composed just of the digits 0, 1, 2, 3.
1, 11, 101, 1001, 10001, 100001, 684917, 1000001, 10000001, 100000001, 1000000001, 10000000001, 100000000001, 1000000000001, 10000000000001, 100000000000001, 1000000000000001, 10000000000000001, 100000000000000001, 1000000000000000001
Offset: 1
Programs
-
Mathematica
Do[ If[ Union[ IntegerDigits[ n^3 ] ] [ [ -1 ] ] < 4, Print[ n ] ], {n, 1, 10^9, 2} ] (* corrected by Friedjof Tellkamp, Apr 24 2025 *) (* faster code *) DigitsLEQ3[n_] := And @@ (LessEqual[#, 3] & /@ IntegerDigits[n]) Arr = {1, 7}; For[i = 1, i < 10, i++, Arr = Flatten[Table[Select[Arr + 10^i j, DigitsLEQ3[Mod[#^3, 10^(i+1)]] &], {j, 0, 9}]]]; Select[Arr, DigitsLEQ3[#^3] &] (* Friedjof Tellkamp, Apr 25 2025 *)
-
Python
A031997_list = [n for n in range(1,10**6,2) if max(str(n**3)) <= '3'] # Chai Wah Wu, Feb 23 2016
Extensions
Term 0 removed and a(12)-a(17) added by Chai Wah Wu, Feb 25 2016
a(18)-a(20) from Giovanni Resta, Mar 14 2020
Comments