Series programs part 2
Write a program to print the following series.
Series part 1
Series programs part 2
Write a program to print the following series.
0, 4,18,48,100.....n
import java.io.*;
class series
{
public static void main()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a number of ur choice");
int n=Integer.parseInt(br.readLine());
int a=1;
while(a<=n)
{
double b=(int)Math.pow(a,2);
double c=(int)Math.pow(a,3);
double num=(int)c-b;
System.out.print(num+",");
a++;
}
}
}Write a java program to solve the following series
1+(1+2)+(1+2+3)+(1+2+3+4)+…..(1+2+3+4…….+n)
import java.io.*;
class series3
{
public static void main()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a number of ur choice");
int n=Integer.parseInt(br.readLine());
int sum=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
sum+=j;
}
}
System.out.println(sum);
}
}Write a program to print the following series
4, 9, 16,25,.....
import java.io.*;
class series5
{
public static void main()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a number of ur choice");
int n=Integer.parseInt(br.readLine());
int sum=0;
for(int i=2;i<=n;i++)
{
double sq=Math.pow(i,2);
sum+=sq;
}
System.out.println(sum);
}
}https://youtu.be/DjipqnsypVs
Related Posts
Continue learning with these related articles

String Methods in Java for ICSE Class 10: 25 Output Questions with Answers
ICSE Class 10 Computer Applications practice on String class methods: length, charAt, indexOf, lastIndexOf, substring, replace, trim, compareTo, equals and more, with 25 board-style output questions and step-by-step answers.

Special Number Programs in Java for ICSE: Armstrong, Spy, Neon, Disarium, Pronic and More
Every special number asked in ICSE Computer Applications – prime, perfect, Armstrong, palindrome, automorphic, neon, spy, Niven, duck, buzz, Disarium, special and pronic numbers – with definitions, examples and one complete Java program that checks them all.

Math Library Methods in Java for ICSE Class 9 (with Outputs)
ICSE Class 9 Computer Applications notes on the Java Math class: sqrt, cbrt, pow, abs, max, min, ceil, floor, round, rint and random, with return types, tricky negative-number outputs and Java expressions for formulas.