Elm

Other Elm solutions.
module DifferenceOfSquares exposing (difference, squareOfSum, sumOfSquares)

import List exposing (foldl, map, range)


sum : List Int -> Int
sum =
    foldl (+) 0


squared : Int -> Int
squared x =
    x ^ 2


squareOfSum : Int -> Int
squareOfSum n =
    sum (range 1 n) ^ 2


sumOfSquares : Int -> Int
sumOfSquares n =
    range 1 n
        |> map squared
        |> sum


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

Roc

Other Roc solutions.
module [squareOfSum, sumOfSquares, differenceOfSquares]

# squareOfSum : U64 -> U64
# squareOfSum = \number ->
#     loop =
#         \sum ->
#             if sum == number then
#                 sum
#             else
#                 sum + loop (sum + 1)
#     summation = loop 1
#     Num.powInt summation 2

squareOfSum : U64 -> U64
squareOfSum = \number ->
    List.sum (List.range { start: At 1, end: At number }) |> Num.powInt 2

sumOfSquares : U64 -> U64
sumOfSquares = \number ->
    List.map
        (List.range { start: At 1, end: At number })
        \n -> n * n
    |> List.sum

differenceOfSquares : U64 -> U64
differenceOfSquares = \number ->
    squareOfSum number - sumOfSquares number