Project Euler #61: Cyclical figurate numbers

  • + 0 comments

    For those who hate hard coding each individual equations

    def gon(N, n):
        return ((N-2) * n**2 + (4-N) * n) // 2
    

    Triangular(n) -> gon(3, n), Square(n) -> gon(4, n), Pentagon(n) - gon(5, n), ...