1public class Numbers {
2 public static void FibannaciNumbers(int n) {
3 int x = 0;
4 int y = 1;
5 if(n >= 1) {
6 System.out.print(x + " ");
7 }
8 if(n >= 2) {
9 System.out.print(y);
10 }
11 if (n > 2) {
12 for(int a = n - 2; a > 0; a--) {
13 int z = y + x;
14 System.out.print(" " + z);
15 x = y;
16 y = z;
17 }
18 }
19 }
20}
1def fibonacci(n):
2 if n <= 0:
3 return 0
4 elif n == 1:
5 return 1
6 else:
7 return fibonacci(n-1) + fibonacci(n-2)
1// Copy paste code here https://play.golang.org/
2package main
3
4import "fmt"
5
6func fibo(n int) int {
7 x, y := 0, 1
8 for i := 0; i < n; i++ {
9 x, y = y, x+y
10 }
11 return x
12}
13
14func main() { fmt.Println(fibo(5)) } // return 5
1// Copy pastecode here https://play.golang.org/
2package main
3
4import "fmt"
5
6func fibo(n int) int {
7 x, y := 0, 1
8 for i := 0; i < n; i++ {
9 x, y = y, x+y
10 }
11 return x
12}
13
14func main() {
15 for i := 0; i < 10; i++ {
16 fmt.Println("fibo of", i, "is", fibo(i))
17 }
18}
19
1//x is the index number in the fibonnacci sequence.
2//The function will return that index's fibonacci value
3function fib(x) {
4 let a = 0;
5 let b = 1;
6 for (var i = 0; i < x-1; i++) {
7 let c = b;
8 b += a;
9 a = c;
10 }
11 return b;
12}
1function myFib(n) {
2 if (isNaN(n) || Math.floor(n) !== n)
3 return "Not an integer value!";
4 if (n === 0 || n === 1)
5 return 3;
6 else
7 return myFib(n - 1) + myFib(n - 2);
8}
9
10console.log(myFib(5));
11
12
13
1
2int n ;
3double feb = (1/Math.pow(5,0.5)) * (Math.pow((1+Math.pow(5,0.5))/2,n)) - (1/Math.pow(5,0.5))* (Math.pow((1-Math.pow(5,0.5))/2,n));