Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: Project Euler #01 on HackerRank, Performance issue?
(Frerich Raabe)
----------------------------------------------------------------------
Message: 1
Date: Wed, 28 Jan 2015 12:12:50 +0100
From: Frerich Raabe <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Project Euler #01 on HackerRank,
Performance issue?
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8; format=flowed
On 2015-01-28 00:57, Jean Lopes wrote:
> I'm not really good at math, maybe I am missing something obvious ?
> Maybe some pointers as of where to start studying math in order to avoid
> this brute force attempts, at least to help in this particular
> problem
I'm not too familiar with 'Project Euler', but summing all multiples of 3 and
5 below some given 'n' made me think: e.g. 16 it
would be...
3 + 5 + 6 + 9 + 10 + 12 + 15
= 3 + 6 + 9 + 12 + 15 + 5 + 10 | reordered summands
= 3 + 6 + 9 + 12 + 15 + 5 + 10 + 15 - 15 | +15-15 appended to
prepare factoring out
= 3 + 6 + 9 + 12 + 15 + 5 + 10 + 15 - 15 | whitespace for
readability
= 3 * (1+2+3+4+5) + 5 * (1+2+3) - 15 * (1) | factoring out
Now I remembered a trick to get the sum of the first N numbers (I only
remember it's called "der kleine Gau?" in german):
1 + 2 + ... + n = (n^2 + n) / 2
Maybe that'll help.
- Frerich
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 79, Issue 36
*****************************************