Answers for "write a java program to fibonacci series"

2

write a java program to fibonacci series

public class Fibonacci {

    public static void main(String[] args) {

        int n = 10, t1 = 0, t2 = 1;
        System.out.print("First " + n + " terms: ");

        for (int i = 1; i <= n; ++i)
        {
            System.out.print(t1 + " + ");

            int sum = t1 + t2;
            t1 = t2;
            t2 = sum;
        }
    }
}
Posted by: Guest on July-14-2020

Code answers related to "write a java program to fibonacci series"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language