You are viewing a single comment's thread. Return to all comments →
Haskell
import Control.Applicative import Control.Monad import System.IO sqSumTo :: Int -> Int sqSumTo n = ((n * (n+1)) `div` 2 ) ^ 2 sumSqTo :: Int -> Int sumSqTo n = sum [x * x | x <- [1..n]] main :: IO () main = do t_temp <- getLine let t = read t_temp :: Int forM_ [1..t] $ \a0 -> do n_temp <- getLine let n = read n_temp :: Int print (sqSumTo n - sumSqTo n)
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Project Euler #6: Sum square difference
You are viewing a single comment's thread. Return to all comments →
Haskell