Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int total = 0;
- public int triangle(int rows) {
- if (rows == 0) {
- return total;
- }
- if (rows == 1) {
- return total + 1;
- }
- else {
- total += rows;
- rows--;
- triangle(rows);
- }
- return total;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement