Java Programs

Fibonacci series in Java

public class FibonacciExample {
public static void main(String[] args) {
int n1 = 0, n2 = 1, n3, count = 15;
System.out.print(n1 + " " + n2);
for (int i = 2; i < count; i++) {
n3 = n1 + n2;
n1 = n2;
n2 = n3;
System.out.print(" " + n3);
}
}
}

运行结果

0 1 1 2 3 5 8 13 21 34 55 89 144 233 377

参考资料

Java Programs的更多相关文章

  1. Thinking in Java——笔记(18)

    I/O The original byte-oriented library was supplemented with char-oriented, Unicode-based I/O classe ...

  2. Java性能提示(全)

    http://www.onjava.com/pub/a/onjava/2001/05/30/optimization.htmlComparing the performance of LinkedLi ...

  3. Java Garbage Collection Basics--转载

    原文地址:http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/gc01/index.html Overview Purpose ...

  4. JAVA fundamentals of exception handling mechanism

    Agenda Three Categories Of Exceptions Exceptions Hierarchy try-catch-finally block The try-with-reso ...

  5. Core Java Volume I — 3.3. Data Types

    3.3. Data TypesJava is a strongly typed language(强类型语音). This means that every variable must have a ...

  6. Core Java Volume I — 3.1. A Simple Java Program

    Let’s look more closely at one of the simplest Java programs you can have—one that simply prints a m ...

  7. Java常用类:String

    一.介绍 String:不可变的Unicode字符序列     例如:"Java"   就是4个Unicode字符J,a,v,a组成的 Java没有内置的字符串类型,而是在标准的J ...

  8. Java String Class Example--reference

    reference:http://examples.javacodegeeks.com/core-java/lang/string/java-string-class-example/ 1. Intr ...

  9. Getting Started with Java

    “学前”说明:<Learn Java for Android>这本书内容很多,都是精华,建议大家看英文版的.在这里我不打算一一总结书中的内容,书中每章节后面的exercises都很好,非常 ...

随机推荐

  1. 下载网页视频音频方法(djyeye为例)

    方法一: 三步操作: 选择media即可. m4a即为音频实际地址. 方法二: 方法三: 遨游浏览器 感谢知乎 https://www.zhihu.com/question/26938393

  2. 对于redis框架的理解(四)

    上一篇讲述了eventloop的结构和创建,添加文件事件删除文件事件,派发等等. 而eventloop主要就是调用不同网络模型完成事件监听和派发的. 这一篇主要讲述epoll网络模型,redis是如何 ...

  3. 装饰器--decorator2

    装饰器加参数 import time def timer(func): # timer(test2) func = test2 def deco(): start_time = time.time() ...

  4. Qt每次运行都是重新编译问题

    按理说,Qt使用了makefile技术只会编译刚修改的源文件,但有时会遇到一运行项目就会重新编译的问题,严重浪费了时间. 问题就出在你的系统时间上,系统时间的不准确会影响makefile机制的判断过程 ...

  5. Asp.net mvc 大文件上传 断点续传 进度条

    概述 项目中需要一个上传200M-500M的文件大小的功能,需要断点续传.上传性能稳定.突破asp.net上传限制.一开始看到51CTO上的这篇文章,此方法确实很不错,能够稳定的上传大文件,http: ...

  6. POJ3061 Subsequence 尺取or二分

    Description A sequence of N positive integers (10 < N < 100 000), each of them less than or eq ...

  7. hihocoder1415 后缀数组三·重复旋律3

    传送门:http://hihocoder.com/problemset/problem/1415 [题解] 考虑求出两串合在一起(中间加分隔符)后缀数组,就是要求任意在两个串中的$i, j$,$\mi ...

  8. 【CodeForces】899 F. Letters Removing

    [题目]F. Letters Removing [题意]给定只含小写字母.大写字母和数字的字符串,每次给定一个范围要求删除[l,r]内的字符c(l和r具体位置随删除变动),求m次操作后的字符串.n&l ...

  9. 认识单点登录cas

    么是单点登录?单点登录全称Single Sign On(以下简称SSO),是指在多系统应用群中登录一个系统,便可在其他所有系统中得到授权而无需再次登录,包括单点登录与单点注销两部分 1.登录 相比于单 ...

  10. python学习笔记(十一)之序列

    之前学习的列表,元组,字符串都是序列类型,有很多共同特点: 通过索引得到每一个元素,索引从0开始 通过分片的方法得到一个范围的元素的集合 很多通用的操作符(重复操作符,拼接操作符,成员关系操作符) 序 ...