Computer Science, asked by anchitha9315, 1 year ago

What is the program to print
2,5,10,17
In java

Answers

Answered by aditya2543
76
import java.util.*;
class series
{
public static void main ()
{
into i, s;
for (i =1;i <=4;i++);
{
s=i*i +1;
System.out.print(s);
}
}
}

Answered by Anonymous
35

The program to print

2,5,10,17....

Output

=>2,5,10,17

=>1×1=1=2

=>2×2+1=5

=>3×3+1=10

=>4×4+1=17

class prog

{

void display()

{

int sum =1 ;

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

{

sum=i*i+1

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

}

}

}

Similar questions