sequence

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2018 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fibonacci

func Fibonacci(n int64, algo Algorithm) (k *big.Int, err error)

Fibonacci calculates the fibonacci number for the given number.

func GetSequence

GetSequence retreives a Fibonacci sequence for a value n.

Types

type Algorithm

type Algorithm interface {
	F(*big.Int) *Tuple
}

Algorithm is an interface describe the methods required by algorithms.

type FastDoublingMethod

type FastDoublingMethod struct{}

FastDoublingMethod implements the Algorithm interface. It uses the fast doubling method algorithm:

F(2n) = F(n)[2*F(n+1) – F(n)]
F(2n + 1) = F(n)2 + F(n+1)2

where, F(0) = 0, F(1) = 1

func (*FastDoublingMethod) F

func (f *FastDoublingMethod) F(n *big.Int) *Tuple

F implements the Algorithm interface.

type NegativeNumberError

type NegativeNumberError struct{}

NegativeNumberError is a custom error.

func (NegativeNumberError) Error

func (e NegativeNumberError) Error() string

Error implements the Error interface.

type Tuple

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

Tuple represents a tuple.

Jump to

Keyboard shortcuts

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