You are viewing a single comment's thread. Return to all comments →
you can get nth pentagonal number from 3n^2 - n.
pen n = (flip div 2) $ n * (n * 3 - 1) main = getLine >> getContents >>= putStrLn . unlines . map (show . pen . read) . lines
Seems like cookies are disabled on this browser, please enable them to open this website
Pentagonal Numbers
You are viewing a single comment's thread. Return to all comments →
you can get nth pentagonal number from 3n^2 - n.