I\'m writing a function to find triangle numbers and the natural way to write it is recursively:
function triangle (x) if x == 0 then return 0 end retu
Recursion isn't necessary. The nth triangle number is n(n-1)/2, so...
public int triangle(final int n){ return n * (n - 1) / 2; }