OFFSET
1,2
LINKS
Rosetta Code, Kaprekar numbers
Eric Weisstein's World of Mathematics, Kaprekar Number
Wikipedia, Kaprekar number
PROG
(Haskell)
import Data.List (find)
import Data.Maybe (mapMaybe)
a194218 n = a194218_list !! (n-1)
a194218_list = map fst kaprekarPairs
a194219 n = a194219_list !! (n-1)
a194219_list = map snd kaprekarPairs
a006886 n = a006886_list !! (n-1)
a006886_list = map (uncurry (+)) kaprekarPairs
kaprekarPairs = (1, 0) : (mapMaybe (\n -> kSplit n $ splits (n^2)) [1..])
where kSplit x = find (\(left, right) -> left + right == x)
splits q = no0 . map (divMod q) $ iterate (10 *) 10
no0 = takeWhile ((> 0) . fst) . filter ((> 0) . snd)
-- Cf. Rosetta link.
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Reinhard Zumkeller, Aug 19 2011
STATUS
approved