Sha256: ddc240718dfb8e0ecab35d395791d1f972d059ea1fc0722134ceb1d2b70cb1c7

Contents?: true

Size: 404 Bytes

Versions: 396

Compression:

Stored size: 404 Bytes

Contents

module Squares (squareOfSums, sumOfSquares, difference) where

square :: Integral a => a -> a
square n = n * n

squareOfSums :: Integral a => a -> a
squareOfSums n = square $ n * succ n `div` 2

sumOfSquares :: Integral a => a -> a
sumOfSquares n = (2 * n3 + 3 * n2 + n) `div` 6
  where n2 = square n
        n3 = n * n2

difference :: Integral a => a -> a
difference n = squareOfSums n - sumOfSquares n

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.98 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.2.1.97 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.2.1.96 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.2.1.95 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.2.1.94 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.2.1.93 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.2.1.92 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.2.1.91 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.2.1.90 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.2.1.89 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.2.1.88 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.2.1.87 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.2.1.86 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.2.1.85 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.2.1.84 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.2.1.83 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.2.1.82 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.2.1.81 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.2.1.80 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.2.1.79 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs