wap in java to print the following series
Attachments:
Answers
Answered by
0
int i = 1;
while(true)
{
for(int y =0;y<i;y++;)
{
i++;
}
System.out.println(i);
}
if you have a limit then
int i = 1;
int limit = 10;
while(i<10)
{
for(int y =0;y<i;y++;)
{
i++;
}
System.out.println(i);
}
while(true)
{
for(int y =0;y<i;y++;)
{
i++;
}
System.out.println(i);
}
if you have a limit then
int i = 1;
int limit = 10;
while(i<10)
{
for(int y =0;y<i;y++;)
{
i++;
}
System.out.println(i);
}
Answered by
0
import java.util.Scanner;
class Series
{
public static void main()
{
Scanner s = new Scanner(System.in);
System.out.println("Enter value of n:");
int n =sc.nextInt();int s =0;
for(int i =1;i<=n;i++)
{ for(int j=1;j<=i;j++)
{
s =s+;
}
}
System.out.println("Sum is :"+s);
}
}
Similar questions