You are viewing a single comment's thread. Return to all 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), ...
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #61: Cyclical figurate numbers
You are viewing a single comment's thread. Return to all comments →
For those who hate hard coding each individual equations
Triangular(n) -> gon(3, n), Square(n) -> gon(4, n), Pentagon(n) - gon(5, n), ...