[Haskell-beginners] Finding Keith Numbers with Haskell

Rein Henrichs rein.henrichs at gmail.com
Wed Nov 12 01:44:45 UTC 2014

On Tue, Nov 11, 2014 at 5:26 AM, Jack Mott <jack.mott at gmail.com> wrote:

> I did try this approach as well, reversing the digits and adding elements
> to the head, however having to use take and letting the list build  up
> larger seems to result in slightly worse performance overall.

The list doesn't build up. The specification for Keith Numbers requires
that we only sum the previous n numbers, where n is the length of the
decimal encoding of the given number, so we always truncate using take
before the recursive call.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20141111/45603ef3/attachment.html>

More information about the Beginners mailing list