Fibonacci

Fibonacci is a sequence generator that is performant from Int32 all the way up to BigInteger.


Keywords
Fibonacci, sequence, generator, nth, biginteger, PCL
License
MIT
Install
Install-Package Fibonacci -Version 0.2.0

Documentation

Fibonacci Build status

A sequence generator for fibonacci and negafibonacci that is performant from Int32 all the way up to BigInteger. The current implementation of Fibonaci.Nth uses the Fast Doubling algorithm.

There are faster and slower implementations available, feel free to send pull requests through as you see fit. If the algorithm you are submitting is faster than the current one then please change Fibonaci.Nth to use it.

Supported Platforms

  • .NET 4.5 (We are a Profile78 Portable Class Library)
  • Mono
  • Xamarin.iOS
  • Xamarin.Android
  • Xamarin.Mac

Installation

Installation is done via NuGet:

Install-Package Fibonnaci

Usage

using Fibonnaci;

long fib = Fibonaci.Nth(91);                       // 4660046610375530309   
long fib = Fibonaci.Nth(92);                       // ArgumentOutOfRangeException as fib would exceed Int64.MaxValue 

BigInteger fib = Fibonaci.Nth(new BigInteger(92))  // 7540113804746346429
BigInteger fib = Fibonaci.Nth(new BigInteger(100)) // BigInteger.Parse("354224848179261915075")
BigInteger fib = Fibonaci.Nth(new BigInteger(1000) // BigInteger.Parse("43466557686937456435688527675040625802564660517371780402481729089536555417949051890403879840079255169295922593080322634775209689623239873322471161642996440906533187938298969649928516003704476137795166849228875"));

Recommended Reading

With thanks to