Skip to content

Instantly share code, notes, and snippets.

@gkhays
Forked from rahulaga/recursion.java
Created March 26, 2016 23:43
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 gkhays/fa369302be9a7ef2376a to your computer and use it in GitHub Desktop.
Save gkhays/fa369302be9a7ef2376a to your computer and use it in GitHub Desktop.
Recursion
public static void recurse(int n) {
if (n <= 0)
return;
else {
n=n-1;
recurse(n);
System.out.println(n);
return;
}
}
public static void recurse(int n) {
if (n <= 0)
return;
else {
System.out.println(n);
n=n-1;
recurse(n);
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment