Computer Science, asked by vishwas9702, 1 year ago

Wap to print series 1,11,111,...,n

Answers

Answered by Anonymous
1

Code


import java.util.*;

class Series

{

public void main()

{

Scanner sc=new Scanner(System.in);

System.out.println("Enter the limit");

int n=sc.nextInt();

int s=1;

int a=10;

for(int i=0;i<=n;i++)

{

s=s+Math.pow(a,i);

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

}

}


Output

Enter the limit

5

1,11,111,1111,1111


Hope it helps


__________________________________________________________________



Similar questions