Answers for "fibonacci sequence math"

1

fibonacci sequence

public class Numbers {
	public static void FibannaciNumbers(int n) {
        int x = 0;
        int y = 1;
        if(n >= 1) {
            System.out.print(x + " ");
        }
        if(n >= 2) {
            System.out.print(y);
        }
        if (n > 2) {
            for(int a = n - 2; a > 0; a--) {
                int z = y + x;
                System.out.print(" " + z);
                x = y;
                y = z;
            }
        }
    }
}
Posted by: Guest on August-23-2021
1

fibonacci sequence

public class Numbers {
	public static void FibannaciNumbers(int n) {
        int x = 0;
        int y = 1;
        if(n >= 1) {
            System.out.print(x + " ");
        }
        if(n >= 2) {
            System.out.print(y);
        }
        if (n > 2) {
            for(int a = n - 2; a > 0; a--) {
                int z = y + x;
                System.out.print(" " + z);
                x = y;
                y = z;
            }
        }
    }
}
Posted by: Guest on August-23-2021
1

fibinachi

def fib(n):
  lisp = []
  
  for i in range(n):
    if len(lisp) < 3:
      if len(lisp) == 0:
        lisp.append(0)
      else:
        lisp.append(1)
    
    else:
      lisp.append(lisp[len(lisp)-1]+lisp[len(lisp)-2])
  
  return lisp
Posted by: Guest on October-13-2020
1

fibinachi

def fib(n):
  lisp = []
  
  for i in range(n):
    if len(lisp) < 3:
      if len(lisp) == 0:
        lisp.append(0)
      else:
        lisp.append(1)
    
    else:
      lisp.append(lisp[len(lisp)-1]+lisp[len(lisp)-2])
  
  return lisp
Posted by: Guest on October-13-2020

Python Answers by Framework

Browse Popular Code Answers by Language