summaryrefslogtreecommitdiffstats
path: root/006.lua
blob: 3c39a4b8f29461e7f785c6ee066577b1f4b54c2b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
local function sum_of_squares(n)
    local total = 0
    for i = 1, n do
        total = total + i^2
    end
    return total
end

local function square_of_sum(n)
    return n^2*(n+1)^2/4
end

print(square_of_sum(100) - sum_of_squares(100))