I know how to find the nearest triangular number: m = floor(sqrt(2N) T = m(m+1)/2 But that returns the triangular number closest to N. I want the nearest triangular number greater than or equal to N. So if I input 7, I want 10, not 6. Can anyone help me?
https://stackoverflow.com/questions/66591347/how-to-find-the-smallest-triangular-number-greater-than-or-equal-to-n March 12, 2021 at 06:15AM
没有评论:
发表评论