Sha256: 3571cb8a99977917a8354ac86d20eaf843f1a00eb8a651a5fbfc6150e5a1fb4f

Contents?: true

Size: 367 Bytes

Versions: 66

Compression:

Stored size: 367 Bytes

Contents

module DifferenceOfSquares exposing (difference, squareOfSum, sumOfSquares)


squareOfSum : Int -> Int
squareOfSum n =
    let
        sum =
            n * (n + 1) // 2
    in
    sum * sum


sumOfSquares : Int -> Int
sumOfSquares n =
    List.sum (List.map (\m -> m * m) (List.range 0 n))


difference : Int -> Int
difference n =
    squareOfSum n - sumOfSquares n

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/elm/exercises/difference-of-squares/DifferenceOfSquares.example.elm
trackler-2.2.1.179 tracks/elm/exercises/difference-of-squares/DifferenceOfSquares.example.elm
trackler-2.2.1.178 tracks/elm/exercises/difference-of-squares/DifferenceOfSquares.example.elm
trackler-2.2.1.177 tracks/elm/exercises/difference-of-squares/DifferenceOfSquares.example.elm
trackler-2.2.1.176 tracks/elm/exercises/difference-of-squares/DifferenceOfSquares.example.elm
trackler-2.2.1.175 tracks/elm/exercises/difference-of-squares/DifferenceOfSquares.example.elm
trackler-2.2.1.174 tracks/elm/exercises/difference-of-squares/DifferenceOfSquares.example.elm
trackler-2.2.1.173 tracks/elm/exercises/difference-of-squares/DifferenceOfSquares.example.elm
trackler-2.2.1.172 tracks/elm/exercises/difference-of-squares/DifferenceOfSquares.example.elm
trackler-2.2.1.171 tracks/elm/exercises/difference-of-squares/DifferenceOfSquares.example.elm
trackler-2.2.1.170 tracks/elm/exercises/difference-of-squares/DifferenceOfSquares.example.elm
trackler-2.2.1.169 tracks/elm/exercises/difference-of-squares/DifferenceOfSquares.example.elm
trackler-2.2.1.167 tracks/elm/exercises/difference-of-squares/DifferenceOfSquares.example.elm
trackler-2.2.1.166 tracks/elm/exercises/difference-of-squares/DifferenceOfSquares.example.elm
trackler-2.2.1.165 tracks/elm/exercises/difference-of-squares/DifferenceOfSquares.example.elm
trackler-2.2.1.164 tracks/elm/exercises/difference-of-squares/DifferenceOfSquares.example.elm
trackler-2.2.1.163 tracks/elm/exercises/difference-of-squares/DifferenceOfSquares.example.elm
trackler-2.2.1.162 tracks/elm/exercises/difference-of-squares/DifferenceOfSquares.example.elm
trackler-2.2.1.161 tracks/elm/exercises/difference-of-squares/DifferenceOfSquares.example.elm
trackler-2.2.1.160 tracks/elm/exercises/difference-of-squares/DifferenceOfSquares.example.elm