ADEUF3JLP3EAYNMIEV73MMHEX5KJS4UJHHJWYQHVDKDWGWIDVHKAC
var sum uint64
for i := 1; i < 65; i++ {
tmp, err := Square(i)
if err != nil {
return 0
}
sum += tmp
// 2^63 + 2^62 + ... + 2^1 + 2^0
// which means we have to flip all bits to 1 in an uint64
var total uint64
return ^total
}
// SumSquare returns the total number of grains to n-th square.
// SumSquare(64) == Total()
func SumSquare(n int) (uint64, error) {
if n < 1 || n > 64 {
return 0, fmt.Errorf("input must be positive and <= 64, got: %q", n)