Triangle of eights

  • 4
  • Locked
Using a for loop, display a right triangle of eights, with a base of 10 and a height of 10. Example output: 8 88 888 8888 88888 888888 8888888 88888888 888888888 8888888888
You can't complete this task, because you're not signed in.
Comments (4)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Anonymous #10962697
Level 10 , Knoxville, United States
12 September 2022, 17:29
for(int i =1; i <= 10; i++){ String hello = "8"; System.out.print(hello.repeat(i)); System.out.println(""); }
Siyanda Dlamini
Level 7 , Durban, South Africa
12 March 2022, 17:06
This challenge really threw me off but I learned something new about nested loops
BobbyGWilly
Level 6 , United States of America, United States
25 January 2022, 18:47
3rd Requirement false fail. output is definitely 10 lines with 1-10 8's
for (int i=0,j=1; i<=10; i++) {
   for (int e=1; e<j; e++) {
      System.out.print("8");
   }
   System.out.printf("%n");
}
BobbyGWilly
Level 6 , United States of America, United States
25 January 2022, 19:55
got this to pass instead...
for (long i=0,j=1; i<=9; i++) {
    System.out.println(8*j);
    j=Long.parseLong(j+"1");
}