Енчо обнови решението на 01.11.2016 08:30 (преди над 1 година)
+package main
+
+func sumSquares(n uint64) uint64 {
+ var sum uint64
+ for i := uint64(1); i <= n; i++ {
+ sum += i * i
+ }
+ return sum
+}
+
+func squareSum(n uint64) uint64 {
+ var sum uint64
+ for i := uint64(1); i <= n; i++ {
+ sum += i
+ }
+ return sum * sum
+}
+
+// SquareSumDifference calculates the sum difference
+func SquareSumDifference(n uint64) uint64 {
+ sumSquareResult := sumSquares(n)
+ squareSumResult := squareSum(n)
+
+ return squareSumResult - sumSquareResult
+}