From 87bf8703297843c923c3785ad6ba59f33c34aebc Mon Sep 17 00:00:00 2001 From: lalmendra <109772135+lalmendra@users.noreply.github.com> Date: Mon, 10 Aug 2026 00:04:07 -0300 Subject: [PATCH] fix nested loops in nested_loops.md In the first two examples, decrementing `x` inside the inner loop causes the loop to run indefinitely. Also fixed the third example to keep the same pattern. --- src/loops/nested_loops.md | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/loops/nested_loops.md b/src/loops/nested_loops.md index 2de9c34..fea955b 100644 --- a/src/loops/nested_loops.md +++ b/src/loops/nested_loops.md @@ -9,16 +9,17 @@ int y = 3; while (x != 0) { while (y != 0) { - IO.println( - "x is " + x - ); IO.println( "y is " + y ); - x--; y--; } + + IO.println( + "x is " + x + ); + x--; } ~} ``` @@ -36,16 +37,17 @@ while (x != 0) { break; } - IO.println( - "x is " + x - ); IO.println( "y is " + y ); - x--; y--; } + + IO.println( + "x is " + x + ); + x--; } ~} ``` @@ -62,16 +64,17 @@ while (x != 0) { while (y != 0) { - IO.println( - "x is " + x - ); IO.println( "y is " + y ); - x--; y--; } + + IO.println( + "x is " + x + ); + x--; } ~} ```