Print Fibonacci Sequcnce

简介:
public   class  Fibonacci {

    
private   static   int  MAX  =   100 ;
    
/*
     * print the Fibonacci sequence for values < MAX
     
*/
    
public   static   void  main(String[] args) {
        
int  currentVal     =   1 ;
        
int  nextVal         =   1 ;
        
while (currentVal < MAX){
            System.out.println(currentVal);
            nextVal 
=  nextVal  +  currentVal ;
            currentVal 
=  nextVal  -  currentVal;
        }
    }
}
本文转自BlogJavaOo缘来是你oO的博客,原文链接:Print Fibonacci Sequcnce,如需转载请自行联系原博主。
相关文章
|
8月前
|
IDE Java Shell
聊聊 print 的前世今生
聊聊 print 的前世今生
77 1
|
2月前
|
JavaScript 前端开发 Java
print_numbers_up_to 函数介绍
【10月更文挑战第20天】
63 12
|
4月前
|
Python
ValueError: sleep length must be non-negative
ValueError: sleep length must be non-negative
128 3
|
7月前
|
机器学习/深度学习 C语言
每日一数——使用函数求Fibonacci数
每日一数——使用函数求Fibonacci数
|
测试技术
LeetCode 204. Count Primes
统计所有小于非负整数 n 的质数的数量。
53 0
LeetCode 204. Count Primes
|
存储
TypeError: can only concatenate str (not “int“) to str
TypeError: can only concatenate str (not “int“) to str
416 0
TypeError: can only concatenate str (not “int“) to str
|
运维 测试技术 Python
自带的 print 函数居然会报错?(上)
最近用 Python 写了几个简单的脚本来处理一些数据,因为只是简单功能所以我就直接使用 print 来打印日志。
|
缓存 Java Go
自带的 print 函数居然会报错?(下)
最近用 Python 写了几个简单的脚本来处理一些数据,因为只是简单功能所以我就直接使用 print 来打印日志。
ZCMU - 1990: Fibonacci
ZCMU - 1990: Fibonacci
87 0