A360822 Numbers whose squares have at most 2 digits less than 8.
1, 2, 3, 4, 5, 6, 7, 8, 9, 13, 14, 17, 22, 23, 27, 28, 29, 30, 31, 33, 43, 53, 63, 67, 77, 83, 91, 93, 94, 97, 99, 141, 167, 173, 197, 283, 293, 297, 298, 303, 313, 314, 316, 447, 583, 707, 767, 833, 836, 917, 943, 947, 1378, 2917, 2983, 3033, 5467, 9417, 9433, 29983, 31367, 94863
Offset: 1
Examples
314641 is in the sequence, because 314641^2 = 98998958881 has only two digits that are less than 8.
Links
- Michael S. Branicky, Python program
Crossrefs
Cf. A360803.
Programs
-
Mathematica
Select[Range[10^5], Count[IntegerDigits[#^2], ?(#1 < 8 &)] < 3 &] (* _Amiram Eldar, Feb 22 2023 *)
-
PARI
isok(k) = #select(x->(x<8), digits(k^2)) <= 2; \\ Michel Marcus, Feb 22 2023
-
Python
def ok(n): return sum(1 for d in str(n**2) if d < "8") < 3 print([k for k in range(1, 10**5) if ok(k)]) # Michael S. Branicky, Feb 22 2023
-
Python
# see link for a faster version to find all terms
-
Python
from itertools import count, islice def A360822_gen(startvalue=1): # generator of terms >= startvalue return filter(lambda n:len(s:=str(n**2))<=s.count('8')+s.count('9')+2,count(max(startvalue,1))) A360822_list = list(islice(A360822_gen(),62)) # Chai Wah Wu, Mar 11 2023
Comments