subject

Write a recursive and an iterative function to calculate the nth element in a Fibonacci sequence. A Fibonacci sequence is defined as the element 1, followed by another 1, and each element thereafter is the sum of the previous two elements. For example, the first 9 elements of a Fibonacci sequence are: 1 2 3 5 8 13 21 34 This famous sequence was originally used to predict the growth of rabbit populations! Once you have each of the functions working for n equal to 40, determine which method is more efficient by timing the two separate function calls and printing out the time required for each method call to return the 40th element in the sequence. Return the 40th element to main and print it. After that, print out a complete Fibonacci sequence from element 1 to element 40, along with its position number. 1 1 2 3

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 20.06.2019 18:02
How should you decide what to wear to an interview? what kind of things should be considered?
Answers: 2
question
Computers and Technology, 22.06.2019 13:30
1. technician a says horsepower information can be used by consumers to compare the power of different automobile engines. technician b says that manufacturers will often list the horsepower output of their engines in the online service information. who is right?
Answers: 2
question
Computers and Technology, 22.06.2019 16:30
Corey set up his presentation for delivery to his team.the information he had to convey was critical to their job performance.he knew he would need a lot of time to explain each point
Answers: 3
question
Computers and Technology, 23.06.2019 13:30
Font size, font style, and are all aspects of character formatting.
Answers: 2
You know the right answer?
Write a recursive and an iterative function to calculate the nth element in a Fibonacci sequence. A...
Questions
question
Mathematics, 22.01.2021 01:10
question
Physics, 22.01.2021 01:10
question
Mathematics, 22.01.2021 01:10
question
Health, 22.01.2021 01:10
Questions on the website: 13722362