Wednesday, December 8, 2010

Java: Fibonacci & Inverted Pyramid

No comments
Fibonacci.java

This class displays numbers following the Fibonacci sequence. A Fibonacci number is a number which is a sum of the previous two numbers in the sequence. By definition, the first and second numbers of Fibonacci are 0 and 1, respectively.

The number of numbers depends on the user's input. An integer is expected to be the input. The code will not catch errors and will instead terminate upon wrong input.

import java.io.IOException;

public class Fibonacci {

public static void main(String[] args) throws IOException {