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.0.4.0 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.0.3.9 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.0.3.8 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.0.3.7 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.0.3.6 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.0.3.5 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.0.3.4 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.0.3.3 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.0.3.2 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.0.3.1 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.0.3.0 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.0.2.0 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.0.1.2 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.0.1.1 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.0.1.0 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.0.0.10 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.0.0.9 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.0.0.8 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.0.0.7 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs
trackler-2.0.0.6 tracks/haskell/exercises/difference-of-squares/examples/success-standard/src/Squares.hs