Computer Science, asked by kritvijain, 6 months ago

Write the programs in Java to display the first ten terms of the foll
(a) 1, 4, 9, 16,
(b) 1, 2, 4, 7, 11, .
(c) 3, 6, 9, 12,
(d) 4, 8, 16, 32,
(e) 1.5, 3.0, 4.5, 6.0,
(f) 0, 7, 26,
(g) 1, 9, 25, 49,
(h) 4, 16, 36, 64,
(i) 0, 3, 8, 15,
(1) 24, 99, 224, 399,
(k) 2, 5, 10, 17,

Answer it correctly or you don't love India instead you support china​

Answers

Answered by anindyaadhikari13
44

Series 1:-

1 4 9 16....

Logic:- 1^2, 2^2,....N^2

Program:-

import java.util.*;

class Series

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

System.out.print("Enter the term for the series: ");

int n=sc.nextInt();

for(int i=1;i<=n;i++)

System.out.print(i*i+" ");

}

}

Series 2:-

1 2 4 7....

Logic:- difference is +1,+2,+3...

Program:-

import java.util.*;

class Series

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

System.out.print("Enter the term for the series: ");

int n=sc.nextInt();

int a=1;

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

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

}

}

Series 3:-

3,6,9,12....N

Logic:- multiples of 3.

Program:-

import java.util.*;

class Series

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

System.out.print("Enter the term for the series: ");

int n=sc.nextInt(), a=3;

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

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

}

}

Series 4:-

4,8,16,32...N

logic:- 4*2=8,8*2=16...

Program:-

import java.util.*;

class Series

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

System.out.print("Enter the term for the series: ");

int n=sc.nextInt(), a=4;

for(int i=1;i<=n;i++,a*=2)

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

}

}

Series 5:-

1.5 3.0 4.5 6.0

Logic:- +1.5

Program:-

import java.util.*;

class Series

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

System.out.print("Enter the term for the series: ");

int n=sc.nextInt();

double d=1.5;

for(int i=1;i<=n;i++,d+=1.5)

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

}

}

Series 6:-

0,7,26..N

logic:- N^3 -1.

Program:-

import java.util.*;

class Series

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

System.out.print("Enter the term for the series: ");

int n=sc.nextInt();

for(int i=1;i<=n;i++)

System.out.print((i*i*i-1)+" ");

}

}

Series 7:-

1,9,25,49

Logic:-1²,3²,5²..

Program:-

import java.util.*;

class Series

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

System.out.print("Enter the term for the series: ");

int n=sc.nextInt(), a=1;

for(int i=1;i<=n;i++,a+=2)

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

}

}

Series 8:-

4,16,36,64

Logic:- 2²,4²,6²...

Program:-

import java.util.*;

class Series

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

System.out.print("Enter the term for the series: ");

int n=sc.nextInt(),a=2;

for(int i=1;i<=n;i++,a+=2)

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

}

}

Series 9:-

0,3,8,15..

Logic:- N²-1

Program:-

import java.util.*;

class Series

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

System.out.print("Enter the term for the series: ");

int n=sc.nextInt();

for(int i=1;i<=n;i++)

System.out.print(i*i-1+" ");

}

}

Series 10:-

24,99,224,399

logic:- 24=4*6,

99=(4+5)*(6+5)

224=14*16(14=9+5, 16=11+5)...

Program:-

import java.util.*;

class Series

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

System.out.print("Enter the term for the series: ");

int n=sc.nextInt(),a=4,b=6;

for(int i=1;i<=n;i++,a+=5,b+=5)

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

}

}

Series 11:-

2 5 10 17..

Logic:- n²+1

Program:-

import java.util.*;

class Series

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

System.out.print("Enter the term for the series: ");

int n=sc.nextInt();

for(int i=1;i<=n;i++)

System.out.print((i*i+1)+" ");

}

}

Similar questions