Wnte a java program to print fibonacci series upto n term: example:if n=5.
fibonacci series = 0 1 1 2 3..........n
Answers
Answered by
11
Answer:
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;
}
}
}
Output
0 + 1 + 1 + 2 + 3 + 5 + 8 + 13 + 2
Explanation:
mark brainliest
Answered by
4
Answer:
The above given answer is absolutely correct follow it up
Similar questions
Math,
3 months ago
Social Sciences,
3 months ago
Computer Science,
8 months ago
English,
1 year ago
Science,
1 year ago