Теодора обнови решението на 01.11.2016 14:39 (преди над 1 година)
+package main
+
+import "fmt"
+
+/*function finding the sum of n numbers*/
+func sumOfN(n uint64) uint64 {
+ var tmpSum uint64
+ var i uint64
+ for i = 0; i <= n; i++ {
+ tmpSum += i
+ }
+ return tmpSum
+}
+
+/*function finding the sum of the squares of n numbers*/
+func sumOfSquares(n uint64) uint64 {
+ var tmpSum uint64
+ var i uint64
+ for i = 0; i <= n; i++ {
+ tmpSum += i*i
+ }
+ return tmpSum
+}
+
+/*function finding the diference betwwen
+the sqare of the sum of n numbers
+and the sum of the sqares of n numbers*/
+func SquareSumDifference(n uint64) uint64 {
+ sumN := sumOfN(n)
+ sqSum := sumOfSquares(n)
+ return sumN*sumN - sqSum
+}
+
+func main() {
+ fmt.Println(SquareSumDifference(10))
+}