兔生兔(斐波那契数列)
作者:互联网
import java.util.Scanner;
public class 兔 {
public static void main(String[] args)
{
int n=new Scanner(System.in).nextInt();
System.out.println(digui(n));
}
private static int digui(int n)
{
int totle = 1;
if (n==1||n==2)
{
totle = 1;
}
if (n>2)
{
totle = digui(n-1)+digui(n-2);
}
return totle;
}
}
import java.util.Scanner;
public class 兔 {
public static void main(String[] args)
{
int n=new Scanner(System.in).nextInt();
System.out.println(digui(n));
}
private static int digui(int n)
{
int totle = 1;
if (n==1||n==2)
{
totle = 1;
}
if (n>2)
{
totle = digui(n-1)+digui(n-2);
}
return totle;
}
}
标签:兔生,totle,int,digui,System,斐波,static,那契,public 来源: https://www.cnblogs.com/shiaguang/p/12340287.html