Answer to Question #4166 in Java | JSP | JSF for naveen

Question #4166
I want to output 0,1,1,2,3,5,8,13,21,34
1
Expert's answer
2011-09-07T05:12:24-0400
public class Fibonacci{ public static void main(String[] args){
int current = 1;
int previous = 0;
int temp =0;
while (current<50){
temp = current;
System.out.println(current);
current = previous + current;
previous = temp;
}
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS