Дойчин обнови решението на 28.10.2016 09:27 (преди над 1 година)
+// Package main is an example solution of the first task in the course for the Go Programming
+// Language in FMI, Sofia University.
+package main
+
+func squareUint64(n uint64) uint64 {
+ return n * n
+}
+
+// SquareSumDifference finds the difference between the square of the sum and the sum of the
+// squares of the first `n` natural numbers.
+func SquareSumDifference(n uint64) uint64 {
+ var sumSquare = squareUint64((n * (n + 1)) / 2)
+ var squaresSum uint64
+ for i := uint64(1); i <= n; i++ {
+ squaresSum += squareUint64(i)
+ }
+ return sumSquare - squaresSum
+}