In this exercise, you will modify this program:
In its current form, the program produces the Fibonacci number for
Fibonacci number for n = 8: 21
Modify line 39 to produce other Fibonacci numbers.
In this exercise, your task is to modify the methods
public List getFibonacciSeries(int n) and
public static void Main() such that the program produces the following output for
Fibonacci sequence for n = 8: [1, 1, 2, 3, 5, 8, 13, 21]
Before you modify the program, make sure that you understand its code. Specifically:
- What does each method do?
- What are the required input parameters, and what are their types?
- What value does the method return, and what is its type?
- What are the steps in which each method creates a result that is returned?
public List<int> getFibonacciSeries(int n) currently does not perform relevant data processing. It simply returns an empty list of integers. You will modify this method as part of this exercise.
Steps to complete the exercise:
- Read and understand the program’s code (see above).
- Create an account on .NET Fiddle.
- Open the program in your .NET Fiddle account.
- Create a new version of the original program by choosing ‘Fork’ in the .NET Fiddle menu.
- Modify the program. ‘Save’ frequently in order not to lose work.
- Copy a link to your fiddle using ‘Share’ > ‘Share Link’.
- Submit the link on TUWEL until Monday, October 16, 5pm.
- Correctness of the Fibonacci sequence.
- Correct formatting of the Fibonacci sequence (values separated by
,with opening and closing brackets
[1, 1, 2, 3, 5, 8, 13, 21].
- Tidy code formatting (this is similar to a professionally drawn floor plan):
- Use indentation (see code examples).
- Consistent formatting.
- Add comments where necessary. This helps you and others understand your code.
- The computation of Fibonacci sequences is not very efficient. Modify your program accordingly and submit it as a separate Fiddle.