Header AD

Fibonacci em Go utilizando Struct e Loop true




Como calcular Fibonaci em Go utilizando Struct e for true

// You can edit this code!
// Click here and start typing.

package main

import "fmt"

type Fibo struct {
	b int
	a int
}

func CalcFibo(x int) {
	f := Fibo{0, 1}
	fmt.Printf("%d %d", f.b, f.a)
	f.b = f.a
	f.a *= 2
	for {
		fmt.Printf(" %d", f.a)
		f.b = f.a - f.b
		f.a = f.a + f.b
		if f.a > x {
			break
		}
	}
}

func main() {
	CalcFibo(8)
}



Postar um comentário

Post a Comment (0)

Postagem Anterior Próxima Postagem

Follow

Header AD

Last Video

Header AD