new grains exercise.
non tail-recursive version.