0
Is there a way i can write this code using any loop and still get the same output?
public class Example{ public static void main(String []args){ System.out.println("1"); System.out.println("33"); System.out.println("555"); System.out.println("7777"); System.out.println("99999"); } }
4 Answers
+ 11
public class Main {
public static void main(String[] args) {
for (int i=1;i<=5;i++)
{
System.out.println((Integer.toString((i*2)-1)).repeat(i));
}
}
}
+ 2
In python:
for i in range(1,6):
print(i*str(i*2-1))
0
Thanks
0
Am getting an error saying method repeat(int) is unidentified for type string