Answers for "java fibonacci sequence without recursion"

2

java fibonacci sequence without recursion

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 "java fibonacci sequence without recursion"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language