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. poj 1743 后缀数组 最长不重叠子串

    Musical Theme Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 30941   Accepted: 10336 D ...

  2. 「Django」rest_framework学习系列-分页

    分页a.分页,看第N页,每页显示N条数据方式一:使用PageNumberPagination创建分页对象,配合settings全局配置 views设置 from rest_framework.pagi ...

  3. phpstrom+xdebug+chrome+postman调试工具搭建

    php是解释性语言,大部分调试的时候使用var_dump+exit就可以搞定了,但是在大项目或遇到了负载的问题的时候你就需要断点调试.变量打印.性能分析了,php也有非常程序的解决方案,我们现在就动手 ...

  4. Jquery中find与each方法使用详解

    本文实例讲述了jQuery中find与each方法用法.分享给大家供大家参考.具体如下: 一.find()方法 jquery选择器非常强大,利用css的命名规约,可以更快更方便的找出想要的元素. 图解 ...

  5. 「LibreOJ β Round #4」游戏

    https://loj.ac/problem/524 题目描述 qmqmqm和sublinekelzrip要进行一场游戏,其规则是这样的: 首先有一个序列,其中每个位置是一个整数或是X.双方轮流将X的 ...

  6. 2-sat基础题 BZOJ 1823

    http://www.lydsy.com/JudgeOnline/problem.php?id=1823 1823: [JSOI2010]满汉全席 Time Limit: 10 Sec  Memory ...

  7. Flying to the Mars

    D - Flying to the Mars Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I ...

  8. [译] man 7 pthreads

    NAME      pthreads - POSIX threads   DESCRIPTION      POSIX.1 指定了一组叫做POSIX线程或Pthreads的编程接口(函数,头文件).单 ...

  9. 【CodeForces】671 C. Ultimate Weirdness of an Array

    [题目]C. Ultimate Weirdness of an Array [题意]给定长度为n的正整数序列,定义一个序列的价值为max(gcd(ai,aj)),1<=i<j<=n, ...

  10. vc6列表框多选时,获取哪些项被选中

    //vc6列表框多选时,获取哪些项被选中...... void CWebcyzDlg::OnButton2() { int n = m_mylist1.GetSelCount();//首先获取一共有多 ...