Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Bunny Ears
- private int ears = 0;
- public int bunnyEars(int bunnies) {
- if (bunnies > 0) {
- ears += 2;
- bunnies--;
- bunnyEars(bunnies);
- }
- return ears;
- }
- //////////////////////////////////////
- // Triangle
- int total = 0;
- public int triangle(int rows) {
- if (rows == 0) {
- return total;
- }
- else {
- total += rows;
- rows--;
- triangle(rows);
- }
- return total;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement