java求助贴,求一个数列的第n项,斐波那契数列前10项为 1,1,2,3,5,8,13,21,34,55
classtest4{staticvoidmain(String[]args){shuchu(5);}staticvoidshuchu(intn);intx=1;inty...
class test4
{
static void main(String[] args)
{
shuchu(5);
}
static void shuchu(int n);
int x =1;int y =1;int z = 0;
for(int d = 2;d<n;d++);
{
z=x+y;
x = y;
y = z;
}
System.out.print(z)
} 展开
{
static void main(String[] args)
{
shuchu(5);
}
static void shuchu(int n);
int x =1;int y =1;int z = 0;
for(int d = 2;d<n;d++);
{
z=x+y;
x = y;
y = z;
}
System.out.print(z)
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询