Skip to content

Instantly share code, notes, and snippets.

@gulan
Created December 9, 2019 22:55
Show Gist options
  • Select an option

  • Save gulan/31219869906230a2f1c49dc507546260 to your computer and use it in GitHub Desktop.

Select an option

Save gulan/31219869906230a2f1c49dc507546260 to your computer and use it in GitHub Desktop.
module CombinatorialHierarchy where
{- https://en.wikipedia.org/wiki/Combinatorial_hierarchy
3, 2^3-1, 2^7-1, 2^127-1
seq:
3, 7, 127, 170141183460469231731687303715884105727
cumulative sum:
3, 10, 137, 170141183460469231731687303715884105864
-}
combinatorialHierarchy = cumSum (take 4 (conseq 3))
where conseq :: Integer -> [Integer]
conseq n = n : conseq (nxt n)
nxt n = 2^n - 1
cumSum = scanl1 (+)
main = print combinatorialHierarchy
{-
$ ghci CombinatorialHierarchy.hs
...
> main
[3,10,137,170141183460469231731687303715884105864]
>
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment