projecteuler-go/pe28/pe28.go
2021-06-06 08:06:55 -05:00

20 lines
349 B
Go

package pe28
import (
"fmt"
)
func Solve(_ []string) {
max_width := 1001
sum := 1
for width := 1; width < max_width; width += 2 {
width_squared := width * width
sum += width_squared + width + 1 +
width_squared + 2*(width+1) +
width_squared + 3*(width+1) +
width_squared + 4*(width+1)
}
fmt.Println("Sum of diagonals =", sum)
}