Write a program finding the sum of Fibonacci Numbers upto 200 in Bluej.
Answers
Answered by
1
Answer:
If you have any problem related to it ask me down:
Attachments:
atrs7391:
please again comment me if it works as I didn't tested as I am now on my phone
Answered by
3
Required Answer:-
Question:
- Write a program to find out the sum of Fibonacci Numbers below 200 in Java.
Solution:
Here is the program.
public class FibonacciSum {
public static void main(String[] args) {
int a=1, b=0, c=0;
int s=0;
while(c<=200) {
s+=c;
c=a+b;
a=b;
b=c;
}
System.out.println("Sum: "+s);
}
}
Explanation:
- We will just calculate each term of series and store the sum in variable s. If the term of the series exceeds 200, the loop will be terminated.
Output is attached.
Attachments:
Similar questions