Skip to content

Instantly share code, notes, and snippets.

@chaoxu
Created December 6, 2011 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chaoxu/1438142 to your computer and use it in GitHub Desktop.
Save chaoxu/1438142 to your computer and use it in GitHub Desktop.
Partition number in Haskell, using https://gist.github.com/1438136
integers = 0 : concat [[x,(-x)] | x <- [1..]]
generalizedPentagonalNumbers = [(3 * n^2 - n) `div` 2|n<-integers]
partitionNumbers = rec [1] (cycle [1,1,-1,-1]) (tail generalizedPentagonalNumbers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment