Computer Science, asked by abhiakhi, 1 year ago

how to display the first ten numbers of the fibonacci series using a for loop

Answers

Answered by 521
1
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; } } }

521: i hope i will help
abhiakhi: thanks
521: no problem dude
521: thanks for the thanks
Similar questions