OFFSET
0,4
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 0..300
J. H. Conway, On Happy Factorizations, J. Integer Sequences, Vol. 1, 1998, #1.
Reinhard Zumkeller, Initial Happy Factorization Data for n <= 250
PROG
(Haskell)
a007968 = (\(hType, _, _, _, _) -> hType) . h
h 0 = (0, 0, 0, 0, 0)
h x = if a > 0 then (0, a, a, a, a) else h' 1 divs
where a = a037213 x
divs = a027750_row x
h' r [] = h' (r + 1) divs
h' r (d:ds)
| d' > 1 && rest1 == 0 && ss == s ^ 2 = (1, d, d', r, s)
| rest2 == 0 && odd u && uu == u ^ 2 = (2, d, d', t, u)
| otherwise = h' r ds
where (ss, rest1) = divMod (d * r ^ 2 + 1) d'
(uu, rest2) = divMod (d * t ^ 2 + 2) d'
s = a000196 ss; u = a000196 uu; t = 2 * r - 1
d' = div x d
hs = map h [0..]
hCouples = map (\(_, factor1, factor2, _, _) -> (factor1, factor2)) hs
sqrtPair n = genericIndex sqrtPairs (n - 1)
sqrtPairs = map (\(_, _, _, sqrt1, sqrt2) -> (sqrt1, sqrt2)) hs
-- Reinhard Zumkeller, Oct 11 2015
CROSSREFS
KEYWORD
nonn
AUTHOR
STATUS
approved