Jule J.

asked • 06/04/21

fibonacci array recursive

below is the code. how can i make the for loop in bold so that this method is a recursive function

public void Fibonacci_Array(int[] nums)

{

if(nums == null || nums.Length <= 0)

{

return;

}

nums[0] = 0;

if(nums.Length >= 2)

{

nums[1] = 1;

}


for (int i = 2; i < nums.Length; i++)

{

nums[i] = nums[i - 1] + nums[i - 2];

}

}

1 Expert Answer

By:

Patrick B. answered • 06/04/21

Tutor
4.7 (31)

Math and computer tutor/teacher

Jule J.

i cant add another parameter i only can have an array as a parameter
Report

06/04/21

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.