to print the series in java- 0,3,8,15.....upto 10 terms
Answers
Answered by
24
Java is a machine independent language which can work on any platform. Its an object oriented programming which stress on object rather than data.
The main parts while doing Java programming are package, Class ,input variables, condition updating.
◼The given series follows (square -1 ) pattern.
Example
1×1 = 1 -1 =0
2×2 = 4 - 1 = 3
3 × 3 = 9 - 1 =8
The following programming is done by io package of Java.
import java.io.*;
class series
{
public static void main(String args[])throws Exception
{
int i ,p;
for(i= 1 ;i<=10;i++)
{
p= (i*i)-1;
System.out.print(p+" ");
}
}
}
Answered by
1
Answer:
I am just giving necessary variables and main working of
the loop structures
int n=1, i, res=0;
for(i=1;i<=10;i++)
{
res= 25(n*n)-1;
System.out.print(res +" , ");
n++;
}
}
}
Similar questions