Skip to content

Instantly share code, notes, and snippets.

@thmain
Last active May 27, 2018
Embed
What would you like to do?
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