Project Euler #154: Exploring Pascal's pyramid.

  • + 0 comments

    It seems we can solve all test cases taking advantage of the symmetry of Pascal pyramid level. Every j element in row i (rows are enumarated from very bottom where i = 0 means bottom row) in level n of Pascal pyramid is given by the formula: n! / (i! * j! * (n - i - j)!). Due to symmetry we need to consider only one third of rows. Last but not least, it's very helpful to precompute given prime exponents in all factorials.