https://github.com/uudashr/fibgo
Fibonacci in Go
https://github.com/uudashr/fibgo
algorithm fibonacci
Last synced: 9 months ago
JSON representation
Fibonacci in Go
- Host: GitHub
- URL: https://github.com/uudashr/fibgo
- Owner: uudashr
- License: mit
- Created: 2017-02-24T01:16:59.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-16T08:00:00.000Z (over 8 years ago)
- Last Synced: 2025-01-13T19:48:08.454Z (11 months ago)
- Topics: algorithm, fibonacci
- Language: Go
- Size: 27.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/uudashr/fibgo)
[](https://coveralls.io/github/uudashr/fibgo?branch=master)
# Fibonacci
Provide functionality for fibonacci related operation
## Installation
```shell
$ go get github.com/uudashr/fibgo
```
## Usage
Get fibonacci number of N
```go
import (
"fmt"
fib "github.com/uudashr/fibgo"
)
func ExampleN() {
fmt.Println(fib.N(0))
fmt.Println(fib.N(6))
fmt.Println(fib.N(9))
// Output:
// 0
// 8
// 34
}
```
Or get sequence with length 10
```go
import (
"fmt"
fib "github.com/uudashr/fibgo"
)
func ExampleSeq() {
fmt.Println(fib.Seq(10))
// Output: [0 1 1 2 3 5 8 13 21 34]
}
```
Or create HTTP Service
```go
package main
import (
"log"
"net/http"
fib "github.com/uudashr/fibgo"
)
func main() {
handler := fib.NewHTTPHandler()
log.Println("Listening on port", 8080, "...")
err := http.ListenAndServe(":8080", handler)
log.Println("Stopped err:", err)
}
```
## Running the fibgo service
Fibgo provide the http service for fibonacci numbers.
To run the service
```shell
$ fibgo-server --port 8080
```