Write a programs in java to display the first ten terms of the series:-
1. 1,4,9,16,....................... .
2. 1,2,4,7,11,..................... .
3. 1.5,3.0,4.5,6.0.......... .
4. 0,7,26,.................... .
5. 1,9,25,49,.............. .
6. 4,16,36,64,........... .
7. 0,3,8,15.......... .
8. 24,99,224,399......... .
9. 2,5,10,17,.......... .
Answers
Answer:
try to learn python more easier than java
Question:-
- Write a programs in Java to display first 10 series.
Series 1:-
- 1,4,9,16....10th term
Code Logic:-
- Square of every number from 1 to 10
Code:-
public class Ser1{
public static void main (String ar []){
for(int I=1;I<=10;I++){
System.out.print(Math.pow(I,2)+" ");
}
}
}
________________________
Series 2:-
- 1,2,4,7,11.....10th term
Code:-
public class Ser2{
public static void main (String ar []){
d=1;
for(int I=1;I<=10;I++){
System.out.print(d+" ");
d+=I;
}
}
}
______________________
Series 3:-
- 1.5,3.0,4.5....10th term
Code:-
public class Ser3{
public static void main (String ar [])
for(int I=1;I<=10;I++){
System.out.print((1.5*I)+" ");
}
}
}
______________________
Series 4:-
- 0,7,26....10th term
Code Logic:-
- One subtracted from the cube of number from 1 to 10
Code:-
public class Ser4{
public static void main (String ar[]){
for(int I=1;I<=10;I++){
System.out.print(Math.pow(I,3)-1);
}
}
}
_______________________
Series 5:-
- 1,9,25,49....10th term
Code Logic:-
- Square of odd numbers
Code:-
public class Ser5{
public static void main (String ar []){
int d=1;
for(int I=1;I<=10;I++){
System.out.print(Math.pow(d,2));
d+=2;
}
}
}
__________________________
Series 6:-
- 4,16,36,64,........... .
Code Logic:-
- Square of even numbers
Code:-
public class Ser6{
public static void main (String ar[]){
int d=2;
for(int I=1;I<=10;I++){
System.out.print(Math.pow(d,2));
}
}
}
________________________
Series 7:-
- 0,3,8,15......10th term
Code Logic:-
- 1 subtracted from the square of numbers from 1 to 10
Code:-
public class Ser7{
public static void main (String ar []){
for(int I=1;I<=10;I++){
System.out.print((I*I)-1);
}
}
}
________________________
Series 8:-
- 24,99,224,399....10th term
Code:-
public class Ser8{
public static void main (String ar []){
int d=5;
for(int I=1;I<=10;I++){
System.out.print((d*d)-1);
}
}
}
________________________
Series 9:-
- 2,5,10,17,.......... .
Code:-
public class Ser9{
public static void main (String ar [])
int d=2,k=3;
for(int I=1;I<=10;I++){
System.out.print(d);
d+=k;
}
}
}