Answers for "code for fibonacci sequence"

0

fibonacci sequence

// Copy pastecode here https://play.golang.org/
package main

import "fmt"

func fibo(n int) int {
	x, y := 0, 1
	for i := 0; i < n; i++ {
		x, y = y, x+y
	}
	return x
}

func main() {
	for i := 0; i < 10; i++ {
		fmt.Println("fibo of", i, "is", fibo(i))
	}
}
Posted by: Guest on July-22-2021
0

fibonacci sequence

// Copy pastecode here https://play.golang.org/
package main

import "fmt"

func fibo(n int) int {
	x, y := 0, 1
	for i := 0; i < n; i++ {
		x, y = y, x+y
	}
	return x
}

func main() {
	for i := 0; i < 10; i++ {
		fmt.Println("fibo of", i, "is", fibo(i))
	}
}
Posted by: Guest on July-22-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language