paddockpass/euler_go/ex2/ex2.go
2019-07-19 22:21:21 +02:00

28 lines
323 B
Go

package main
import "fmt"
const max = 4000000
func isEven(b int) bool {
res := b % 2
if res == 0 {
return true
}
return false
}
func main() {
a, c, sum := 1, 3, 0
for b := 1; b < max; b++ {
if isEven(b) {
sum += b
c = (a + b)
a, b = b, c
fmt.Println(c, "=", a, "+", b)
}
}
fmt.Println(sum)
}