Some solutions for the julia path
This commit is contained in:
14
julia/difference-of-squares/difference-of-squares.jl
Normal file
14
julia/difference-of-squares/difference-of-squares.jl
Normal file
@@ -0,0 +1,14 @@
|
||||
"Square the sum of the first `n` positive integers"
|
||||
function square_of_sum(n)
|
||||
return sum(1:n)^2
|
||||
end
|
||||
|
||||
"Sum the squares of the first `n` positive integers"
|
||||
function sum_of_squares(n)
|
||||
return sum((1:n).^2)
|
||||
end
|
||||
|
||||
"Subtract the sum of squares from square of the sum of the first `n` positive ints"
|
||||
function difference(n)
|
||||
return square_of_sum(n) - sum_of_squares(n)
|
||||
end
|
||||
Reference in New Issue
Block a user