Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change in the existing solulion of Exercise18_02 of ch_18 #54

Closed
Sahilkumar19 opened this issue Aug 18, 2023 · 1 comment
Closed

Change in the existing solulion of Exercise18_02 of ch_18 #54

Sahilkumar19 opened this issue Aug 18, 2023 · 1 comment

Comments

@Sahilkumar19
Copy link
Contributor

given solution is completely right ...but here is the more optimized solulion without using any loop after solving the recurrence relation of the fibonacci number we will get a direct formula to get the nth fibonacci term. On further solving the formula we will get the time complexity of this program as golden ration raised to the power n which is equal to O(1.6180)^n.

@HarryDulaney
Copy link
Owner

HarryDulaney commented Aug 22, 2023

Exercise 18.02 says:
"*18.2 (Fibonacci numbers) Rewrite the fib method in Listing 18.2 using iterations."

The purpose of this exercise is actually to use a traditional iterative or looping approach to solving fibinanci numbers.
*The goal is not to write the fastest or most optimized algorithm, but to teach the utility of recursion by contrast with iteration.

closing this as it is not actually an issue*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants