%I M4625 #125 Oct 22 2024 12:57:50
%S 1,9,45,55,99,297,703,999,2223,2728,4879,4950,5050,5292,7272,7777,
%T 9999,17344,22222,38962,77778,82656,95121,99999,142857,148149,181819,
%U 187110,208495,318682,329967,351352,356643,390313,461539,466830,499500,500500,533170
%N Kaprekar numbers: positive numbers n such that n = q+r and n^2 = q*10^m+r, for some m >= 1, q >= 0 and 0 <= r < 10^m, with n != 10^a, a >= 1.
%C 4879 and 5292 are in this sequence but not in A053816.
%C Digital root is either 1 or 9. - _Ezhilarasu Velayutham_, Jul 27 2019
%C Named after the Indian recreational mathematician Dattatreya Ramchandra Kaprekar (1905-1986). - _Amiram Eldar_, Jun 19 2021
%D D. R. Kaprekar, On Kaprekar numbers, J. Rec. Math., Vol. 13 (1980-1981), pp. 81-82.
%D N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
%D David Wells, The Penguin Dictionary of Curious and Interesting Numbers, Penguin Books, NY, 1986, p. 151.
%H Robert Gerbicz, <a href="/A006886/b006886.txt">Table of n, a(n) for n = 1..51514</a> [T. D. Noe computed terms 1 - 1019, Nov 10 2007; R. Gerbicz computed the first 51514 terms, Jul 28 2011]
%H Santanu Bandyopadhyay, <a href="https://www.ese.iitb.ac.in/~santanu/RM7.pdf">Kaprekar Number</a>, Indian Institute of Technology Bombay (Mumbai, India, 2020).
%H Nicholas John Bizzell-Browning, <a href="https://bura.brunel.ac.uk/handle/2438/29960">LIE scales: Composing with scales of linear intervallic expansion</a>, Ph. D. Thesis, Brunel Univ. (UK, 2024). See p. 142.
%H Hans Havermann, <a href="http://chesswanks.com/seq/b006886/">The first 11 million Kaprekar numbers (plus the region around the billionth)</a>.
%H Douglas E. Iannucci, <a href="http://www.cs.uwaterloo.ca/journals/JIS/VOL3/iann2a.html">The Kaprekar Numbers</a>, Journal of Integer Sequences, Vol. 3 (2000), Article 1.2,
%H Douglas E. Iannucci and Bertrum Foster, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL8/Iannucci/iannucci45.html">Kaprekar Triples</a>, Journal of Integer Sequences, Vol. 8 (2005), Article 05.4.8.
%H Robert Munafo, <a href="http://www.mrob.com/pub/seq/kaprekar.html">Kaprekar Sequences</a>.
%H Rosetta Code, <a href="http://rosettacode.org/wiki/Kaprekar_numbers">Kaprekar numbers</a>.
%H Walter Schneider, <a href="http://web.archive.org/web/2004/www.wschnei.de/digit-related-numbers/kaprekar-numbers.html">Kaprekar Numbers</a>, 2002.
%H GĂ©rard Villemin's Almanach of Numbers, <a href="http://villemin.gerard.free.fr/Wwwgvmm/Iteration/Kaprekar.htm#Nombre">Nombres de Kaprekar</a>
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/KaprekarNumber.html">Kaprekar Number</a>.
%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Kaprekar_number">Kaprekar number</a>.
%H <a href="/index/Coi#Colombian">Index entries for Colombian or self numbers and related sequences</a>
%F a(n) = A194218(n) + A194219(n) and A194218(n) concatenated with A194219(n) gives a(n)^2. - _Reinhard Zumkeller_, Aug 19 2011
%e 703 is a Kaprekar number because 703 = 494 + 209, 703^2 = 494209.
%t (* This Mathematica code computes five additional powers in order to be sure that all the Kaprekar numbers have been computed. This fix works for mx <= 50, which includes terms computed by Gerbicz. *)
%t Inv[a_, b_] := PowerMod[a, -1, b]; mx = 20; t = {1}; Do[h = 10^k - 1; d = Divisors[h]; d2 = Select[d, GCD[#, h/#] == 1 &]; If[Log[10, h] < mx, AppendTo[t, h]]; Do[q = d2[[i]]*Inv[d2[[i]], h/d2[[i]]]; If[Log[10, q] < mx, AppendTo[t, q]], {i, 2, Length[d2] - 1}], {k, mx + 5}]; t = Union[t] (* _T. D. Noe_, Aug 17 2011, Aug 18 2011 *)
%t kaprQ[\[Nu]_] := Module[{n = \[Nu]^2},
%t MemberQ[Plus @@ # & /@
%t Select[Table[{Floor[n/10^j], 10^j*FractionalPart[n/10^j]}, {j,
%t IntegerLength@n - 1}], #[[2]] != 0 &], \[Nu]]];
%t Select[Range@1000000, kaprQ] (* _Hans Rudolf Widmer_, Oct 22 2021 *)
%o (Haskell) -- See A194218 for another version
%o a006886 n = a006886_list !! (n-1)
%o a006886_list = 1 : filter chi [4..] where
%o chi n = read (reverse us) + read (reverse vs) == n where
%o (us,vs) = splitAt (length $ show n) (reverse $ show (n^2))
%o -- _Reinhard Zumkeller_, Aug 18 2011
%Y See A053816 for another version.
%Y Cf. A037042, A053394, A053395, A053396, A053397, A045913, A003052.
%Y Cf. A193992 (where 10^n-1 occurs in A006886), A194232 (first differences).
%Y Subsequence of A248353.
%K nonn,nice,base,easy,changed
%O 1,2
%A _Robert Munafo_
%E More terms from _Michel ten Voorde_, Apr 11 2001
%E 4879 and 5292 added by Larry Reeves (larryr(AT)acm.org), Apr 24 2001
%E 38962 added by Larry Reeves (larryr(AT)acm.org), May 23 2002