Fibonacci Series in Java

Java code written to count and output the Fibonacci sequence.

// Algorithm for Adding Fibonacci Numbers

// @author www.mikestratton.net
public class Fibonacci
{

public static void main(String[] args)
{

int count = 20; // set the number of times the equation runs ** do not exceed 44
int x = 0; int y = 1; // set the initial values to be added
int fib = 0; //  fibonacci number

for (int i = 0; i <= count; i++)
{
fib = x + y;
x = y;
y = fib;
System.out.println(fib);

}
}

}

https://github.com/mikestratton/Fibonacci

0
  Related Posts