0% found this document useful (0 votes)
5 views1 page

Java Fibonacci Sequence Algorithm

Uploaded by

Makine Andrei
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Java Fibonacci Sequence Algorithm

Uploaded by

Makine Andrei
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Fibonaccijava algoritm :

public class Fibonacci {


public static void main ( String [] args ) {
int n0 = 1 , n1 = 1 , n2; // Initialize variables
[Link] ( n0 + " " + // Print first and second terms
n1 + " " ) ; // of the series

for ( int i = 0 ; i < 18 ; i++ ) { // Loop for the next 18 terms


n2 = n1 + n0; // Next term is sum of previous two
[Link] ( n2 + " " ) ; // Print it out
n0 = n1;

n1 = n2;
}
[Link] () ;

}
}

You might also like