Last active
May 27, 2018 18:33
-
-
Save thmain/e5caec8baebeaa6ffdf0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StepsPossiblePathsRecur { | |
public int possibleWays(int n) { | |
if (n < 1) { | |
return 0; | |
} | |
return 1 + possibleWays(n - 1) + possibleWays(n - 2) | |
+ possibleWays(n - 3); | |
} | |
public static void main(String[] args) { | |
// TODO Auto-generated method stub | |
int n = 3; | |
StepsPossiblePathsRecur s = new StepsPossiblePathsRecur(); | |
System.out.println(s.possibleWays(n)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment