This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A054791 #15 Sep 06 2022 13:23:50 %S A054791 0,1,3,4,9,6,25,8,49,16,11,100,13,144,15,196,81,18,289,20,361,22,441, %T A054791 24,529,36,27,676,29,784,31,900,33,1024,35,1156,625,38,1369,40,1521, %U A054791 42,1681,44,1849,46,2025,48,2209,64,51,2500,53,2704,55,2916,57,3136,59 %N A054791 Earliest sequence with a(a(n)) = n^2. %H A054791 T. D. Noe, <a href="/A054791/b054791.txt">Table of n, a(n) for n = 0..1000</a> %H A054791 <a href="/index/Aa#aan">Index entries for sequences of the a(a(n)) = 2n family</a> %F A054791 if n is a square then a(n) = a(sqrt(n))^2, otherwise if the difference between n and the highest square less than n is odd then a(n) = n+1, otherwise a(n) = (n-1)^2. %t A054791 a[n_] := a[n] = Which[r = Sqrt[n]; IntegerQ[r], a[r]^2, OddQ[n - Floor[r]^2], n+1, True, (n-1)^2]; a[0]=0; a[1]=1; Table[a[n], {n, 0, 58}] (* _Jean-François Alcover_, Aug 07 2012, after formula *) %o A054791 (Haskell) %o A054791 a054791 n = a054791_list `genericIndex` n %o A054791 a054791_list = 0 : 1 : f 2 where %o A054791 f x | r ^ 2 == x = a054791 r ^ 2 : f (x + 1) %o A054791 | odd (x - r) = x + 1 : f (x + 1) %o A054791 | otherwise = (x - 1) ^ 2 : f (x + 1) %o A054791 where r = a000196 x %o A054791 -- _Reinhard Zumkeller_, Oct 27 2013 %Y A054791 Cf. A002516. %K A054791 nice,nonn %O A054791 0,3 %A A054791 _Henry Bottomley_, Apr 27 2000