Make java program that print the following using loop:
1
121
12321
121
1
Answers
Answered by
1
Answer:
public class one
{
public static void main(String args[])
{
int i,r;
String s;
for(i=1,s="1";i<=3;i++,s=s+"1")
{
r=Integer.parseInt(s);
System.out.println(r*r);
}
int m=2;
while(i>0&&m>0)
{
i--;
s=s.substring(0,m);
r=Integer.parseInt(s);
System.out.println(r*r);
i--;
m--;
s=s.substring(0,m);
}
}
}
Similar questions