Skip to content

Instantly share code, notes, and snippets.

@jsbonso
Created October 14, 2017 08:31
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 jsbonso/7e1dc479a8ace33201c2603c9c4fb21b to your computer and use it in GitHub Desktop.
Save jsbonso/7e1dc479a8ace33201c2603c9c4fb21b to your computer and use it in GitHub Desktop.
Simple Recursive Method
/**
* A simple recursive method that outputs numbers from 1 - 10
* @param number of times the method will recurse / repeat
* @return
*/
static int recursiveMethod(int num) {
// An important line, which defines the case when will the recursion ends
if (num == 0)
return num;
System.out.println(num);
// Call itself
return recursiveMethod(num-1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment