Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
RazerStvH authored Oct 29, 2024
1 parent 311f8b3 commit 9f8e123
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
# fibonacchi-go
A simple program for calculating Fibonacci numbers

## How to use

```bash
$ git clone https://github.com/RazerStvH/fibonacchi-go.git
$ cd fibonacchi-go
$ go build fibonacchi-go.go
$ ./fibonacchi-go
```
22 changes: 22 additions & 0 deletions fibonacchi-go.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package main

import (
"fmt"
)

// Recursive function for calculating the n-th Fibonacci number
func fibonacci(n int) int {
if n <= 1 {
return n
}
return fibonacci(n-1) + fibonacci(n-2)
}

func main() {
var n int
fmt.Print("Enter the number of the Fibonacci number: ")
fmt.Scanln(&n)

result := fibonacci(n)
fmt.Printf("Fibonacci(%d) = %d\n", n, result)
}

0 comments on commit 9f8e123

Please sign in to comment.