我正在尝试刷新我的伪代码理解,并想知道写出Fibonacci数字@n的正确方法是什么。
鉴于代码:
public class FibAtN{
public static void main(String args[]){
int j = 0;
int k = j;
int l = 1;
int n =; /*input*/
for(int i=0;i<n;i++){
j=k;
k=l;
l=j+k;
}
System.out.println(j);
}
}
伪代码的正确使用会不会?
PROGRAM FibonnacciAtN
INITIALIZE four integers (say: j,k,l,n)
SET j equal zero, k equal j, l equal 1
SET n equal to INPUT
FOR (integer count is less than n, INCREMENT count every loop) DO
SET j=k, k=l, l=j+k
PRINT integer j
谢谢!