Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java recursion

// prints x number of $
public static void recursion(int x) {
  if(x == 0) { // base case
    System.out.println();
  } else { // recursive case
    System.out.print("$");
    recursion(x - 1);
  }
}
Source by introcs.cs.princeton.edu #
 
PREVIOUS NEXT
Tagged: #java #recursion
ADD COMMENT
Topic
Name
1+2 =