Решение на Разлика в сумите от Станимир Станков

Обратно към всички решения

Към профила на Станимир Станков

Резултати

  • 0 точки от тестове
  • 0 бонус точки
  • 0 точки общо
  • 0 успешни тест(а)
  • 4 неуспешни тест(а)

Код

package main
import "fmt"
func main() {
fmt.Print("Въведи число: ")
var n uint64
fmt.Scan(&n)
var squareRange uint64 = 0
var sum uint64 = 0
var diff uint64 = 0
for n > 0 {
sum += n
squareRange += n * n
n--
}
diff = sum*sum - squareRange
println(diff)
}

Лог от изпълнението

# _/tmp/d20161101-5193-4bvsrp
./solution_test.go:10: undefined: SquareSumDifference
./solution_test.go:34: undefined: SquareSumDifference
./solution_test.go:47: undefined: SquareSumDifference
./solution_test.go:55: undefined: SquareSumDifference
FAIL	_/tmp/d20161101-5193-4bvsrp [build failed]
# _/tmp/d20161101-5193-4bvsrp
./solution_test.go:10: undefined: SquareSumDifference
./solution_test.go:34: undefined: SquareSumDifference
./solution_test.go:47: undefined: SquareSumDifference
./solution_test.go:55: undefined: SquareSumDifference
FAIL	_/tmp/d20161101-5193-4bvsrp [build failed]
# _/tmp/d20161101-5193-4bvsrp
./solution_test.go:10: undefined: SquareSumDifference
./solution_test.go:34: undefined: SquareSumDifference
./solution_test.go:47: undefined: SquareSumDifference
./solution_test.go:55: undefined: SquareSumDifference
FAIL	_/tmp/d20161101-5193-4bvsrp [build failed]
# _/tmp/d20161101-5193-4bvsrp
./solution_test.go:10: undefined: SquareSumDifference
./solution_test.go:34: undefined: SquareSumDifference
./solution_test.go:47: undefined: SquareSumDifference
./solution_test.go:55: undefined: SquareSumDifference
FAIL	_/tmp/d20161101-5193-4bvsrp [build failed]

История (1 версия и 0 коментара)

Станимир обнови решението на 01.11.2016 00:47 (преди над 1 година)

+package main
+
+import "fmt"
+
+func main() {
+ fmt.Print("Въведи число: ")
+ var n uint64
+ fmt.Scan(&n)
+
+ var squareRange uint64 = 0
+ var sum uint64 = 0
+ var diff uint64 = 0
+
+ for n > 0 {
+ sum += n
+ squareRange += n * n
+ n--
+ }
+
+ diff = sum*sum - squareRange
+
+ println(diff)
+}