This post we will see how to write Fibonacci series through Go Lang.
We will use the standard package fmt and the functions within the package.
package main
import (
"fmt"
)
func main()
fmt.Println(" Fibonacci number Series Program in Go Language")
var totalNumber int
// This will read the total numbers to be printed
fmt.Scan(&totalNumber)
num1 := 0
num2 := 1
fmt.Println(num1)
fmt.Println(num2)
sum := num1 + num2
//First two numbers are printed initially
for startValue:=1;startValue < totalNumber;startValue++
fmt.Println(sum)
num1 = num2
num2 = sum
sum = num1 + num2
You can find more go Lang programs here
https://github.com/enstenr/go-repo/tree/main/go-lang-learning
Comments
Post a Comment