How to print 1, 11,111,1111...n using java

 / common way to write 

int a=1,n=10 ;  // n value you can take anything

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

{

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

a=a*10+1;

}


Comments

Post a Comment

Popular posts from this blog