import java.io.*;
public class fibobo{
public static void main(String[] args)
{
String value = "";
int order,n = 0;
order = Integer.parseInt(args[0]);
for(n = 1;n <= order;n++)
{
value += Integer.toString(fibo(n));
value += " ";
}
System.out.println(value);
}
private static int fibo (int n)
{
int t = 2;
int value = 1;
int subvalue = 1;
int tempvalue =0;
if (n == 1)
{
return value;
}
else if (n == 2)
{
return value;
} else
{
for(t = 3;t <= n ;t++)
{
tempvalue = value;
value += subvalue;
subvalue = tempvalue;
}
return value;
}
}
}
最終更新:2012年01月12日 11:51