mirror of
https://codeberg.org/andyscott/exercism.git
synced 2024-11-09 13:20:48 -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);
|
|
}
|