Пламен обнови решението на 26.10.2016 18:20 (преди над 1 година)
+package main
+
+func main() {}
+
+// SquareSumDifference returns the difference between the square of the sum and the sum of suqares of the first n natural numbers.
+func SquareSumDifference(n uint64) uint64 {
+ nums := make([]uint64, 0, n)
+ for i := uint64(1); i <= n; i++ {
+ nums = append(nums, i)
+ }
+
+ var squareSum, sumSquares uint64
+ for _, v := range nums {
+ sumSquares += v * v
+ squareSum += v
+ }
+ return squareSum*squareSum - sumSquares
+}