using the switch statement in java print the series 2,3,5,8,,,,,,,,,20 times
Answers
Answered by
3
CORRECT QUESTION.
- Write a Java program to display the series - 2, 3, 5, 8, . . . 20 terms.
THE CODE.
public class Series{
public static void main(String s[]){
for(int i=1,a=2;i<=20;a+=i++)
System.out.print(a+" ");
}
}
LOGIC.
- First term of this series is 2.
- Difference between each term goes like - 1, 2, 3, 4, . . . N
See the attachment for output.
Attachments:
![](https://hi-static.z-dn.net/files/d38/7ed3e192d877982287c7759780b7b530.jpg)
Similar questions
Biology,
1 month ago
Chemistry,
1 month ago
Science,
1 month ago
Social Sciences,
3 months ago
English,
3 months ago
Math,
11 months ago
World Languages,
11 months ago