mirror of
https://codeberg.org/andyscott/exercism.git
synced 2024-12-22 14:43:10 -05:00
19 lines
396 B
Zig
19 lines
396 B
Zig
pub fn squareOfSum(number: usize) usize {
|
|
var sum: usize = 0;
|
|
for (0..number + 1) |i| {
|
|
sum += i;
|
|
}
|
|
return sum * sum;
|
|
}
|
|
|
|
pub fn sumOfSquares(number: usize) usize {
|
|
var sum: usize = 0;
|
|
for (1..number + 1) |i| {
|
|
sum += i * i;
|
|
}
|
|
return sum;
|
|
}
|
|
|
|
pub fn differenceOfSquares(number: usize) usize {
|
|
return squareOfSum(number) - sumOfSquares(number);
|
|
}
|