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 (3)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Siyanda Dlamini
Level 7 , Durban, South Africa
12 March, 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, 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, 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");
}