login
Number of numbers x < 10^n such that the digits of x^2 occur with an equal frequency of 2.
5

%I #10 May 12 2023 12:27:53

%S 0,1,9,47,212,1232,6592,31145,129587,597959

%N Number of numbers x < 10^n such that the digits of x^2 occur with an equal frequency of 2.

%C The first 47 terms of A052049 and A052050 list the numbers x. Note that n-digit numbers x must be greater than floor(sqrt(10) * 10^(n-1)). All terms after a(10) will equal a(10).

%e The only two-digit number is 88, whose square is 7744.

%t cnt = 0; Table[x = Floor[Sqrt[10] * 10^(n-1)]; While[x < 10^n, If[Union[Last[Transpose[Tally[IntegerDigits[x^2]]]]] == {2}, cnt++]; x++]; cnt, {n, 6}]

%o (Python)

%o from collections import Counter

%o def passes(x): return set(Counter(str(x**2)).values()) == {2}

%o def afull():

%o c = 0

%o for n in range(1, 11):

%o c += sum(1 for x in range(10**(n-1), 10**n) if passes(x))

%o print(c, end=", ")

%o afull() # _Michael S. Branicky_, May 12 2023

%Y Cf. A052049, A052050, A225429 (first differences), A226796 (single digits).

%K nonn,base

%O 1,3

%A _T. D. Noe_, Jun 21 2013

%E a(10) from _Hugo Pfoertner_, May 12 2023