How to print 1,12,123,1234...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.println(a+",");

a=a*10+i;

}

Comments

Popular posts from this blog