login
Numbers with all digits odd whose squares have only one odd digit.
1

%I #33 Mar 20 2022 14:24:56

%S 1,3,5,7,9,15,17,51,53,79,91,93,151,155,157,533,535,775,779,793,917,

%T 1557,1571,1575,5179,5333,5335,7759,7799,9317,9393,9395,15557,15559,

%U 15755,51595,53179,53333,53335,77759,79151,79175,93917,151151,155135,155191

%N Numbers with all digits odd whose squares have only one odd digit.

%C Of course, the one odd digit in the square is always the last digit.

%C The sequence is infinite because it contains the family of numbers 5, 53, 533, 5333, ....... with squares 25, 2809, 284089, 28440889, 2844408889. .... and respectively 535, 5335, 53335, ... with squares 286225, 28462225, 2844622225, 284446222225, ... - _Marius A. Burtea_, May 21 2021

%e 53179 is a term: all its digits are odd, and 53179^2 = 2828006041 has only one odd digit.

%e 15113133375599 is a term: all its digits are odd, and 15113133375599^2 = 228406800428644424408608801 has only one odd digit.

%t Select[Range[160000], AllTrue[IntegerDigits[#], OddQ] && AllTrue[Most @ IntegerDigits[#^2], EvenQ] &] (* _Amiram Eldar_, May 20 2021 *)

%o (Python)

%o def ok(n):

%o r, s = str(n), str(n*n)

%o return all(d in "13579" for d in r) and all(d in "02468" for d in s[:-1])

%o print(list(filter(ok, range(1, 155192, 2)))) # _Michael S. Branicky_, May 20 2021

%o (Python)

%o from itertools import product

%o 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

%o (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

%Y Cf. A014261, A030098, A343726, A343728.

%K nonn,base

%O 1,2

%A _Jon E. Schoenfield_, May 20 2021