Fibonacci in Java with recursion [duplicate]

0

Do I need to create a class or not?

import java.util.Scanner;

 public class Fibonacci {
     public static int main (String[] args) {
        //inicio do codigo
        int fib = 0, count=0, soma=0;
        Scanner entrada = new Scanner (System.in);
        fib = entrada.nextInt();
            if(fib == 0 || fib == 1) return fib;
            else {
                soma = (fib-1) + (fib-2);
            }
            return soma;

            System.out.println("Valor total:"+soma);
            System.out.println("Contador:"+count);
    }
}
    
asked by anonymous 27.10.2017 / 18:55

0 answers