The goal for this exercise is to make sure that you can create and use a List to solve an interesting (i.e., non-contrived) problem
What you need to do to prepare for this exercise:
In the starter project, add code to the Fibonnaci_With_List
class, so that the RunExercise
method does the following:
Create an List<>
of integers
Write a loop which will fill in the next 10 entries in Fibonacci numbers, where
Fibonacci(0) = 0
Fibonacci(1) = 1
Fibonacci(n) = Fibonacci(n – 1) + Fibonacci(n – 2)You should set things up so that Fibonacci(0) is stored in element 0 of your List, Fibonacci(1) is stored in slot 1, etc.
YOu can do this by manually set the first two entries of the List<> to be 0 and 1
It may be useful to review the 'indexer' approach to accessing elements of the list, which allow you to access individual elemetns using an array-style syntax.
Print out all the numbers in the collection.
Please note that because of the List, you do NOT need to solve this problem recursively. In fact, for this exercise, make sure that you don't solve it recursively – use a loop, instead. If you go looking for help online, you will almost certainly find many, recursive examples.