A343727 Numbers with all digits odd whose squares have only one odd digit.
1, 3, 5, 7, 9, 15, 17, 51, 53, 79, 91, 93, 151, 155, 157, 533, 535, 775, 779, 793, 917, 1557, 1571, 1575, 5179, 5333, 5335, 7759, 7799, 9317, 9393, 9395, 15557, 15559, 15755, 51595, 53179, 53333, 53335, 77759, 79151, 79175, 93917, 151151, 155135, 155191
Offset: 1
Examples
53179 is a term: all its digits are odd, and 53179^2 = 2828006041 has only one odd digit. 15113133375599 is a term: all its digits are odd, and 15113133375599^2 = 228406800428644424408608801 has only one odd digit.
Programs
-
Magma
[n:n in [1..160000 by 2]|Set(Intseq(n)) subset {1,3,5,7,9} and Set(Intseq(n*n div 10)) subset {0,2,4,6,8}]; // Marius A. Burtea, May 21 2021
-
Mathematica
Select[Range[160000], AllTrue[IntegerDigits[#], OddQ] && AllTrue[Most @ IntegerDigits[#^2], EvenQ] &] (* Amiram Eldar, May 20 2021 *)
-
Python
def ok(n): r, s = str(n), str(n*n) return all(d in "13579" for d in r) and all(d in "02468" for d in s[:-1]) print(list(filter(ok, range(1, 155192, 2)))) # Michael S. Branicky, May 20 2021
-
Python
from itertools import product A343727_list = [n for n in (int(''.join(d)) for l in range(1,6) for d in product('13579',repeat=l)) if set(str(n**2)[:-1]) <= set('02468')] # Chai Wah Wu, May 21 2021
Comments