%I #21 Jan 09 2017 04:20:03
%S 1,2,13,16667
%N a(n) is the smallest integer m such that sumdigits(m^2) = 4^n.
%C See the Mathematical Reflections link for a proof that a(n) exists for all n.
%C a(4) > 300*10^6.
%C From _Jon E. Schoenfield_, Jan 08 2017: (Start)
%C As shown below, 264575131106460 <= a(4) <= 13663784168010583.
%C The maximal sum of the last three digits of a square is 25, which occurs only when those digits are 889 (e.g., 83^2 = 6889), so since sumdigits(a(4)^2) = 256, the sum of the digits that precede the last three must be at least 256 - 25 = 231, thus a(4)^2 >= 69999999999999999999999999889 (call this number j), so a(4) >= ceiling(sqrt(j)) = 264575131106460. (This bound could easily be improved; e.g., since j is not a square, m^2 cannot be less than the smallest number greater than j whose digit sum is 256 and whose last three digits are 889, i.e., m^2 >= 78999999999999999999999999889, so m >= 281069386451104.)
%C The last digit of a square m^2 is maximized (at 9) iff the last digit of m is 3 or 7. The sum of the last two digits of m^2 is maximized (at 17) iff the last two digits are 89, which occurs iff the last two digits of m are 33, 83, 17, or 67. For k >= 3, it appears that the sum of the last k digits of m^2 is maximized (at 9k-2) iff the last k digits are all 9s except for the two 8s immediately before the final 9, which occurs iff the k-digit suffix of m takes one of eight values, as shown in the table below; the line extending upward from each suffix of more than one digit connects it to the suffix from which it inherits all but its first digit.
%C .
%C k k-digit suffixes of m that maximize sumdigits(m^2 mod 10^k)
%C = ===============================================================
%C 1 3 7
%C / \ / \
%C / \ / \
%C / \ / \
%C / \ / \
%C / \ / \
%C / \ / \
%C / \ / \
%C 2 33 83 17 67
%C |\ |\ |\ |\
%C 3 833 333 583 083 417 917 167 667
%C |\ |\ |\ |\
%C 4 1833 6833 0583 5583 9417 4417 8167 3167
%C |\ |\ |\ |\
%C 5 41833 91833 10583 60583 89417 39417 58167 08167
%C |\ |\ |\ |\
%C 6 041833 541833 010583 510583 989417 489417 958167 458167
%C |\ |\ |\ |\
%C 7 5041833 0041833 8010583 3010583 1989417 6989417 4958167 9958167
%C |\ |\ |\ |\
%C . ... ... ... ... ... ... ... ...
%C .
%C Since numbers m ending in these suffixes have squares m^2 such that sumdigits(m^2 mod 10^k) is maximized, their full digit sums sumdigits(m^2) tend to be larger than those of nearby numbers with other suffixes. A search over a range of prefixes using the 10-digit suffix 4168010583 found that m = 13663784168010583 has sumdigits(m^2) = 256, which yields an upper bound for a(4). (End)
%H Mathematical Reflections, <a href="https://www.awesomemath.org/wp-pdf-files/math-reflections/mr-2014-05/mr_4_2014_solutions.pdf">Solution to Problem J307</a>, Issue 5, 2015, p. 1.
%e a(1)=2 since 2^2=4 with sum of digits 4.
%o (PARI) a(n) = my(k=1); while (sumdigits(k^2) != 4^n, k++); k;
%Y Cf. A000302, A007953, A061912.
%K nonn,base,more
%O 0,2
%A _Michel Marcus_, Jan 08 2017