Static View

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.

Answer:

The complete rule is below.

Static View

Here is the complete math-like definition for the Fibonacci series. There are two base cases. This is fine. Recursion breaks problems into smaller pieces. After enough breaking, all that remains are the base cases that can be solved immediately. There can be any number of base cases.

fib( 1 ) = 1       (base case)

fib( 2 ) = 1       (base case)

fib( N ) = fib( N-1 ) + fib( N-2 )

We have a math-like definition. Creating a Java method to implement it should be a nearly mechanical translation from math to Java.

public int fib( int n )
{
  if (  ) 
  
    return ;
    
  else if  (  ) 
  
    return  ;
    
  else
  
    return  +  ;
}

QUESTION 17:

Sharpen your translation skills by filling those blanks.