Practice: Recursion

Take out a piece of paper. We’ll be programming on paper.

Problem 1

Write a method fibonacci that takes an integer parameter N and returns the Nth fibonacci number.

Fibonacci numbers are defined by the formula Fn = Fn - 1 + Fn - 2. The Fibonacci sequence starts with F0 = 0 and F1 = 1.

Problem 2

Start to write a method

public void printAnagrams(String prefix, String word)

Implement the base case for the recursion.

if word length is one
  Print the prefix and word

Show me your code.