Home » Tip Bank » Java
  • Comment on this Article
Language: Java
Expertise: Intermediate
Feb 17, 2020

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Watch

How to Compute the Fibonacci Number Recursively

The following code shows you how to compute the n Fibonacci number recursively:

int fibonacci(int k) {
    if (k          return k;
    }

    return fibonacci(k - 2) + fibonacci(k - 1);
}
Octavia Anghel
 
Submit a Tip
Browse "Java" Tips
Browse All Tips
sitepoint.com
w3schools.com