Challenge: Compute Sum of N Fibonacci Numbers
Explore how to write a function in Java that computes the sum of the first N Fibonacci numbers. This lesson helps you understand the Fibonacci sequence concept and apply algorithmic thinking to solve programming challenges.
We'll cover the following...
We'll cover the following...
Problem statement
In Mathematics, the Fibonacci sequence or series is defined as a series of numbers in which each number is the sum of the two preceding numbers. The simplest is the series , etc.
- In the given
findTheSumfunction, the numbernis passed as an argument wherenrepresents the number of Fibonacci numbers starting from 1 that we want to compute the sum of.
Expected output
The sum of the first five Fibonacci numbers is 12.