<div dir="ltr">Well I did it pretty dirty, not trying to simplify my solution (I'm skeptic of "k * n/k = n" given that this "n / k" is really "floor (n / k)" ... does this really work for you ?), this gave me :<br><br><span style="font-family:monospace,monospace">import Control.Monad (replicateM_)<br><br>main = do<br>    t <- readLn<br>    replicateM_ t (readLn >>= print . pe1 . subtract 1)<br><br>pe1 n = ( (3 + m3 * 3) * m3 + (5 + m5 * 5) * m5 - (15 + m15 * 15) * m15 ) `quot` 2<br>  where<br>    m3 = n `quot` 3<br>    m5 = n `quot` 5<br>    m15 = n `quot` 15</span><br><div class="gmail_extra"><br><br></div><div class="gmail_extra">Note that the sum of multiples of 3/5/15 can be seen as a sum of terms of an arithmetic sequence which is always "number of terms * (first term + last term) / 2", easily proven by the expedient of writing the sequence twice : one in the right order and the other in reverse under it, you then see that the sum of two term in column is always the same so ...<br><br></div><div class="gmail_extra">-- <br></div><div class="gmail_extra">Jedaï<br></div></div>