import java.util.*;
public class fibo {
public final static int n = 0;
public static String s = "";
public static void main(String[] args) {
Scanner scn = new Scanner (System.in);
System.out.println("Please put in a number.");
int n = scn.nextInt();
s = Integer.toString(n);
System.out.println(n+ ": " + fibonacci(n));
}
public static int fibonacci(int n) {
if(n <= 1)
return n;
else
return fibonacci(n - 1) + fibonacci(n - 2);
}
}
Do'stlaringiz bilan baham: |