Computer Science, asked by anilkumar3856, 10 months ago

Write a program to print 1,11,111,1111 term using loop in java

Answers

Answered by guptavanshika236
0

Answer:

class series

{

public static void main(string args[ ] )

{

int i,s=0,t=0;

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

{

s=s*10+1;

t=t+s;

}

System.out.println(t);

}

}

Explanation:

1st term=0*10+1=1

2nd term=1*10+1=11

.

.

.

so it continues.

The loop runs from 1 to n to take out the terms.

Similar questions