Math, asked by nitutiwari6556, 5 months ago

Write a program in java to print the below series:-

3 , 6, 9, 12, 15, …………50.​

Answers

Answered by anindyaadhikari13
8

Question:-

Write a Java program to display the following series upto 50 terms,

3 6 9 12.....

Program:-

This is an easy question. Read this post to get your answer.

Here comes the program.

public class Series

{

public static void main(String s[])

{

for(int i=1, a=3;i<=50;i++, a+=3)

System.out.print(a+" ");

}

}

How it's solved?

In this program, we have to print first 50 terms of the series 3,6,9,12....

We will create a class, main() function and then create a loop that will iterate 50 times.The initial value of a is 3. After each iteration, the value of a is printed and 3 is added to a. In this way, the program is solved.

Output is attached.

Attachments:
Similar questions