Skip to content

Rudyzio/Fibonacci

Repository files navigation

Fibonacci Calculator

Sample project where you can obtain the nth number in the Fibonacci sequence.

Built With

Technology choices

I choose this stack because is what I feel most comfortable with, except Angular. I didn't worked with Angular these last few years so I gave it a shot. For the interaction with the database I used EF Core and the Repository pattern alongside it, since it is always a good pattern to offer good encapsulation regarding database interaction.

Calculating the nth number

There are various ways to calculate the nth number in the Fibonacci sequence, some more performant than others. Using recursion or even using a list to store the numbers already calculated is one approach, but not the more performant. I knew there were more methods to calculate it so I started searching.

The first one I tried was using the formula Fn = {[(√5 + 1)/2] ^ n} / √5 It didn't worked because of floating point precision: when numbers were bigger, it would always return wrong result.

So I used Matrix exponentiation to make the calculation.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published