In today’s Programming Praxis, our goal is to find the base of the three-sided pyramid that has 169179692512835000 spheres in it. Let’s get started, shall we?
A quick import:
The tetrahedral numbers are based on the triangular numbers, so let’s start with those.
triangular :: [Integer] triangular = scanl1 (+) [1..]
The tetrahedral numbers are formed in much the same way as the triangular ones.
tetrahedral :: [Integer] tetrahedral = scanl1 (+) triangular
All that’s left to do is to is to find the base of the pyramid.
main :: IO () main = print . maybe 0 succ $ findIndex (== 169179692512835000) tetrahedral