fib-go-example: github.com/mtchavez/fib-go-example Index | Examples | Files

package fib

import "github.com/mtchavez/fib-go-example"

Code:

var output int
output = fib(10)
fmt.Printf("Fibonacci of %v is %v\n", 10, output)
output = fib(20)
fmt.Printf("Fibonacci of %v is %v\n", 20, output)

Output:

Fibonacci of 10 is 55
Fibonacci of 20 is 6765

Index

Examples

Package Files

fib.go

type FibStruct Uses

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

func (*FibStruct) Calculate Uses

func (f *FibStruct) Calculate(num int)

Code:

f := FibStruct{}
f.Calculate(10)
fmt.Printf("Fibonacci of %v is %v\n", 10, f.result)

f.Calculate(20)
fmt.Printf("Fibonacci of %v is %v\n", 20, f.result)

Output:

Fibonacci of 10 is 55
Fibonacci of 20 is 6765

Package fib imports 3 packages (graph). Updated 2017-06-19. Refresh now. Tools for package owners.