Java Fibonacci Sequence

Coffee.org-Makes it Easy to Fill your Coffee Mug


This Easy Java Code will produce a set Number of terms of the Fibonacci Sequence




Java


public class Fibonacci {
public static void main(String[] args) {

int n = 30, t1 = 0, t2 = 1;

System.out.print("Fibonacci first " + n + " terms: ");

for (int i = 1; i <= n; ++i){ 

System.out.print(t1 + " + "); 
   
int sum = t1 + t2; t1 = t2; t2 = sum; } } }


Click here to run this code



CyberLink Multimedia Software

More Free Code Examples:



Java Random Numbers






Comments

Popular posts from this blog

Crypto Mining

Multi-tap Keypad Text Entry