Answers for "secuencia de Fibonacci java"

2

fibonacci java

import info1.*;

public class FibonacciDemo1{

  public static void main(String[] args){

    System.out.print("Geben Sie ein Zahl an: ");

    int a = Console.in.readInt();

    System.out.println("fib("+a+") = " + fibonacci(a));

  }

  private static int fibonacci(int a){

    if (a==1||a==2) return 1;

    else return fibonacci(a-1)+fibonacci(a-2);

  }

}
Posted by: Guest on January-18-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language