It's more efficient as no calculation has to be done. Basically the
compiler just inserts a static return value. However it's also possible
that the compiler will make this  substitution automatically as part of its
optimisation routine.
On 23 May 2014 14:31, "Katrina Owen" <notifications@github.com> wrote:

> In grains/example.go:
>
> >  func Total() uint64 {
> > -	var total uint64
> > -	for i := 1; i <= 64; i++ {
> > -		total += Square(i)
> > -	}
> > -	return total
> > +	// the number of grains added up to any point on the board is simply
> > +	// two to the power of that number - 1 (because maths)
> > +	return (1 << 64) - 1
>
> I like this implementation a lot. I'm curious why defining it as a const
> before returning it is more efficient?
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/exercism/xgo/pull/27/files#r12996280>
> .
>