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