Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/uudashr/fibgo
Fibonacci in Go
https://github.com/uudashr/fibgo
algorithm fibonacci
Last synced: 3 days 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 (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-04-16T08:00:00.000Z (over 7 years ago)
- Last Synced: 2024-06-20T06:23:50.343Z (5 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
[![Build Status](https://travis-ci.org/uudashr/fibgo.svg?branch=master)](https://travis-ci.org/uudashr/fibgo)
[![Coverage Status](https://coveralls.io/repos/github/uudashr/fibgo/badge.svg?branch=master)](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 mainimport (
"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
```