3 ms·
2 * (1..12).reduce(&:+) You could also use the closed summation formula: (n^2 + n) / 2. In our case that shortens to just 12*13=156.
by mxbr 7y ago
2 * (1..12).reduce(&:+)
You could also use the closed summation formula: (n^2 + n) / 2. In our case that shortens to just 12*13=156.