class FeiBoNaXieShuLie
{
public static void main(String[] args)
{
System.out.println("Hello World!");
dingli z=new dingli();
z.add(args);
}
}
class dingli
{
void add(String v[])
{
if (v.length!=1)
{
System.out.println("請重新執行,能能輸入壹個數字:");
System.exit(0);
}
int a=Integer.parseInt(v[0]);
if (a>10)
{
System.out.println("請重新執行,能能輸入壹個小於10的數字:");
System.exit(0);
}
int b=0;
for (int c=a;c>=0 ;c-- )
{
System.out.print("菲波那契數列為"+feibo(c));
System.out.println("\t");
}
}
int feibo(int j)
{
int l;
if (j==0||j==1)
{
return j;
}
else
l=feibo(j-1)+feibo(j-2);
//System.out.print(l);
return l;
}
}