Monday, October 5, 2020

Fibonacci Numbers in Go

 I will show you how to write a program using Go programming language to ask the user to give a number and then the program will compute and generate the Fibonacci numbers.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.


My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking and Arduino Project development at a very affordable price.

Program Listing

// fibonacci.go
// Author  : Jake Rodriguez Pomperada, MAED-IT, MIT
// Date    : October 5, 2020   Monday
// Website : www.jakerpomperada.com  / www.jakerpomperada.blogspot.com
// Email   : jakerpomperada@gmail.com
// Place   : Bacolod City, Negros Occidental Philippines

package main

import "fmt"

func main() {
    var n int
    term1 := 0
    term2 := 1
    nextTerm := 0

    fmt.Print("\n\n")
    fmt.Print("\tFibonacci Numbers in Go")
    fmt.Print("\n\n")
    fmt.Print("\tGive a Number : ")
    fmt.Scan(&n)
    fmt.Print("\n")
    fmt.Print("\tFibonacci Series :")
    fmt.Print("\n\n")
    fmt.Print("\t")
    for i := 1; i <= n; i++ {
        if i == 1 {
            fmt.Print(" ", term1)
            continue
        }
        if i == 2 {
            fmt.Print(" ", term2)
            continue
        }
        nextTerm = (term1 + term2)
        term1 = term2
        term2 = nextTerm
        fmt.Print(" ", nextTerm)
    }
    fmt.Print("\n\n")
    fmt.Print("\tEnd of Program")
    fmt.Print("\n\n")
}


No comments:

Post a Comment