Computer Science, asked by alobiswas1977, 5 months ago

write a program to print the following series 0,25,122 in java​

Answers

Answered by anindyaadhikari13
4

Question:-

➡ Write a Java program to print the following series.

0 25 122....N terms.

Program:-

import java.util.*;

class Series

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

int n, i, c=1, x;

System.out.print("Enter the value of n: ");

n=sc.nextInt();

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

{

x=(c*c*c)-i;

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

}

System.out.println("Program Finished.");

}

}

Logic:-

➡ 0 = 1³ - 1

➡ 25 = 3³ - 2

➡ 122 = 5³ - 3

and so on,...

Answered by BrainlyProgrammer
2

Answer:

\huge\star\underbrace{\mathtt\red{⫷❥ᴀ᭄} \mathtt\green{n~ }\mathtt\blue{ §} \mathtt\purple{₩}\mathtt\orange{Σ} \mathtt\pink{R⫸}}\star

\huge\star\underbrace{\mathtt\red{⫷❥LÖGIÇ⫸}}\star

1³-1

2³-2

3³-3

.

.

.

(n^n)-n

\huge\star\underbrace{\mathtt\red{⫷❥ÇØDË⫸}}\star

import java. util. *;

class Series

{

public static void main(String ar[])

{

Scanner sc=new Scanner(System.in) ;

System. out. println("Enter no. of terms") ;

int n=sc.nextInt() ;

int i, c=1, k;

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

{

k=Math.pow(k, 3)-i;

System.out.print(k+", ") ;

}

}

}

Similar questions