+ 3

How to do?

I want a program in java to generate the following series up to 10 terms. 0,3,8,15,24,35,....

25th Nov 2018, 5:34 AM
Jothika
Jothika - avatar
5 Answers
+ 12
jothika Bennett Post //have a look at direct way 😊 ●by seeing the series , it is clear that odd numbers are added after each iteration ● odd number 2*n+1 , ie 3,5,7,9 & so on for n=1,2,3 resp. //so lets use it int a=0,n=1; for(;n<10;n++){ System.out.println(a); a+=2*n+1; }
25th Nov 2018, 6:35 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 3
public class Program { public static void main(String[] args) { int b,a; for(b=3;b<=21;b=b+2) for(a=0;a=a+b) { System.out.println(a); } } } is this how i have to do Bennett Post
25th Nov 2018, 6:01 AM
Jothika
Jothika - avatar
+ 3
25th Nov 2018, 6:15 AM
Jothika
Jothika - avatar
+ 3
27th Nov 2018, 1:44 AM
Jothika
Jothika - avatar
+ 2
There are squere numbers wich reduced by 1 Also you can find it using loop: https://code.sololearn.com/cbW6A1u0o8A4/?ref=app public class Program { public static void main(String[] args) { for(int n = 1; n <= 10; n++) System.out.println(n * n - 1); } }
25th Nov 2018, 11:41 AM
Pavel Zubakha
Pavel Zubakha - avatar