How can I remove duplicated code between classes? : <p>I have 2 class: RecursiveFibonacci and MemorizedRecursiveFibonacci. This is what I have so far. </p>

<p><strong>RecursiveFibonacci Class</strong></p>

<pre><code>public class SimpleRecursiveFibonacci {

  public BigInteger fibonacci(int n) {
    if(n &lt; 2) {
      return BigInteger.ONE;             
    }

    return fibonacci(n - 2).add(fibonacci(n - 1));
  }
}
</code></pre>

<p><strong>and MemorizedRecursiveFibonacci Class</strong></p>

<pre><code>public class MemoizedRecursiveFibonacci {
  private Map&lt;Integer, BigInteger&gt; cache = new HashMap&lt;&gt;();

  public BigInteger fibonacci(int n) {
    if(n &lt; 2) {
      return BigInteger.ONE;
    }
    if(!cache.containsKey(n)){
      BigInteger currentFibonacci = fibonacci(n - 2).add(fibonacci(n - 1));
      cache.put(n, currentFibonacci);
    }

    return cache.get(n);
  }
}
</code></pre>

<p>As I see, there are some duplicated code in MemorizedRecursiveFibonacci Class</p>

<pre><code> if(n &lt; 2) {
      return BigInteger.ONE;
</code></pre>

<p>and </p>

<pre><code>  BigInteger currentFibonacci = fibonacci(n - 2).add(fibonacci(n - 1));
</code></pre>

<p>How can I keep it DRY? remove duplicated code?</p>
