OFFSET
0,3
COMMENTS
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.
MATHEMATICA
r[b_, c_, d_] := (red = Reduce[x > 0 && y > 0 && b*x^2 + d == c*y^2, {x, y}, Integers] /. C[1] -> 1 // Simplify; If[Head[red] === Or, red[[1]], red]); f[n_] := f[n] = If[IntegerQ[rn = Sqrt[n]], {0, rn, rn, rn, rn}, Catch[Do[b = bc[[1]]; c = bc[[2]]; If[c > 1 && (r0 = r[b, c, 1]) =!= False, rr = ToRules[r0]; x0 = x /. rr; y0 = y /. rr; Throw[{1, b, c, x0, y0}]]; If[b > 1 && (r0 = r[c, b, 1]) =!= False, rr = ToRules[r0]; x0 = x /. rr; y0 = y /. rr; Throw[{1, c, b, x0, y0}]]; If[(r0 = r[b, c, 2]) =!= False, rr = ToRules[r0]; x0 = x /. rr; y0 = y /. rr; If[OddQ[x0] && OddQ[y0], Throw[{2, b, c, x0, y0}]]]; If[(r0 = r[c, b, 2]) =!= False, rr = ToRules[r0]; x0 = x /. rr; y0 = y /. rr; If[OddQ[x0] && OddQ[y0], Throw[{2, c, b, x0, y0}]]]; , {bc, Union[Sort[{#, n/#}] & /@ Divisors[n]]}]]]; a[n_] := f[n][[3]]; A007967 = Table[Print["a(", n, ") = ", a[n]]; a[n], {n, 0, 90}] (* Jean-François Alcover, Sep 18 2015 *)
PROG
(Haskell)
import Data.List (genericIndex)
a007967 n = genericIndex a007967_list n
a007967_list = map snd hCouples
-- Pairs hCouples are defined in A007968.
-- Reinhard Zumkeller, Oct 11 2015
CROSSREFS
KEYWORD
nonn,easy,nice
AUTHOR
STATUS
approved