Skip to content

Instantly share code, notes, and snippets.

@thmain
Last active May 27, 2018 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thmain/e5caec8baebeaa6ffdf0 to your computer and use it in GitHub Desktop.
Save thmain/e5caec8baebeaa6ffdf0 to your computer and use it in GitHub Desktop.
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