Print the number series 0 3 8 using while loop in Java
while Loop - Question 6
In this question, we will see how to print the number series 0 3 8 15... up to nth term in Java programming using while loop. To know more about while loop click on the while loop lesson.
Q6) Write a program in Java to print the number series given below using while loop.
0 3 8 15... up to nth term
Program
public class Q6
{
public static void main(String args[])
{
int i=1,s;
while(i<=10)
{
s=(i*i)-1;
System.out.print(s + " ");
i=i+1;
}
}
}
Output
0 3 8 15 24 35 48 63 80 99