Created
November 24, 2015 09:45
-
-
Save ljrk0/d65ddccdc5c93e19ab02 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- sum_{k=1}^{n} k^2 : | |
qSum n = foldr (+) 0 (map (^2) [1..n]) | |
qSumC :: Fractional a => a -> a | |
qSumC n = n * (2*(n^2) + 3*n + 1) / 6 | |
-- bug in haskell?: | |
-- | |
-- try in interactive mode: | |
-- let qs n = n* (2*(n^2) + 3*n + 1) / 6 | |
-- it will give 14.0 for n=3 | |
-- | |
-- qSumC 3 will be 1015.0 ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment