Илко обнови решението на 27.10.2016 10:27 (преди над 1 година)
+package main
+
+import "fmt"
+
+func main() {
+ count := uint64(10)
+ fmt.Println(count)
+ fmt.Println(SquareSumDifference(count))
+}
+
+func SquareSumDifference(n uint64) uint64 {
+ nums := getNumbers(n)
+ fmt.Println(nums)
+ return SquareSum(nums) - SumSquare(nums)
+}
+
+func SquareSum(nums []uint64) (sum uint64) {
+ for _, val := range nums {
+ sum += val
+ }
+ sum = sum * sum
+ fmt.Println("square-sum", sum)
+ return
+}
+
+func SumSquare(nums []uint64) (sum uint64) {
+ for _, val := range nums {
+ sum += val * val
+ }
+ fmt.Println("sum-square", sum)
+ return
+}
+
+func getNumbers(n uint64) (nums []uint64) {
+ for i := uint64(1); i <= n; i++ {
+ nums = append(nums, i)
+ }
+ return
+}