-- Problem 28
module Main (main) where
main :: IO ()
main = print $ problem28
problem28 :: Int
problem28 = calc_iter 1001
calc_iter :: (Integral a) => a -> a
calc_iter n
| n < 1 = error "must be a positive odd."
| even n = error "must be a positive odd."
| n == 1 = 1
| otherwise = 4*n^2 - 6*(n-1) + calc_iter (n-2)
{-
n^2-(n-1) ... n^2
: :
: 1 :
: :
n^2-2*(n-1) ... n^2-3*(n-1)
-}