OFFSET
1,2
COMMENTS
Proof that 1, 2, 3, and 7 are the only values for which a(n)=n. For any n >= 3, n^2 must end in 9 for a(n) to equal n, and so n must end in 3 or 7. a(13) is only 12 because of 81 having a next-to-last digit greater than 6 (from 169). a(17) is only 17 because of 196 having a next-to-last digit greater than 8 (from 289.) Similarly, for any n > 14 to have a(n) equal n, n^2 has to end in 99, for which no square number does. Therefore 1, 2, 3, and 7 are the only values for which a(n) = n.
LINKS
Michael De Vlieger, Table of n, a(n) for n = 1..10000
EXAMPLE
a(8)=3 because only 1, 4, and 64 qualify. (The qualification for n=8 is that the final digit must be at most 4 and the next-to-last digit must be at most 6.)
MAPLE
A162157 := proc(n) local n2dgs, a, k, mtch, ksq, d ; n2dgs := convert(n^2, base, 10) ; a := 0 ; for k from 1 to n do mtch := true; ksq := convert(k^2, base, 10) ; for d from 1 to nops(ksq) do if op(d, ksq)> op(d, n2dgs) then mtch := false; break; fi; od: if mtch then a := a+1; fi; od: a ; end: seq(A162157(n), n=1..80) ; # R. J. Mathar, Jul 04 2009
MATHEMATICA
Table[With[{d = IntegerDigits[n^2]}, Count[Range[n], k_ /; Inner[LessEqual, PadLeft[IntegerDigits[k^2], Length@ d], d, And]]], {n, 80}] (* Michael De Vlieger, Feb 24 2019 *)
CROSSREFS
KEYWORD
nonn,base
AUTHOR
J. Lowell, Jun 26 2009
EXTENSIONS
a(14) inserted and sequence extended by R. J. Mathar, Jul 04 2009
STATUS
approved