fibonacci

package
v0.0.0-...-524e303 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnimplemented       = status.Error(codes.Internal, "unimplemented")
	ErrNotfound            = status.Error(codes.NotFound, "is not a fibonacci number")
	ErrTypeAssertionFailed = status.Error(codes.Internal, "type assertion failed")
	ErrTooBig              = status.Error(codes.OutOfRange, "too big")
	ErrInvalidIndex        = status.Error(codes.InvalidArgument, "invalid index, index must be grater than or equal to zero.")
	ErrInvalidNumber       = status.Error(codes.InvalidArgument, "invalid number")
	ErrInvalidBitSize      = status.Error(codes.InvalidArgument, "invalid bit size")
)

Functions

This section is empty.

Types

type Fibonacci

type Fibonacci struct {
	// contains filtered or unexported fields
}

func New

func New(ops ...Option) (*Fibonacci, error)

func (*Fibonacci) F

func (f *Fibonacci) F(n int) (*big.Int, error)

F : calculate the nth element of the fibonacci series.

func (*Fibonacci) Next

func (f *Fibonacci) Next(n *big.Int) (*big.Int, error)

Next returns the next value of the fibonacci serries. F(IndexOf(n)+1) returns error ErrNotfound : if the n is not a valid fibonacci number ErrTooBig : if the n bit size is bigger than configuration. ErrInvalidNumber : if the n is less than zero.

type IFibonacci

type IFibonacci interface {

	// Next returns the next value of the fibonacci serries. F(IndexOf(n)+1)
	// returns error
	// ErrNotfound : if the n is not a valid fibonacci number
	// ErrTooBig : if the n bit size is bigger than configuration.
	Next(n *big.Int) (*big.Int, error)

	// F calculates the nth element of the fibonacci series.
	F(n int) (*big.Int, error)
}

type Option

type Option func(*Fibonacci) error

func OptionWithCaching

func OptionWithCaching(v bool) Option

func OptionWithMaxBitSize

func OptionWithMaxBitSize(v int) Option

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL