221V 1 week ago
parent
commit
84bfbdf5b4
1 changed files with 13 additions and 12 deletions
  1. 13 12
      exercises/012_while2.zig

+ 13 - 12
exercises/012_while2.zig

@@ -20,16 +20,17 @@
 //
 const std = @import("std");
 
-pub fn main() void {
-    var n: u32 = 2;
-
-    // Please set the continue expression so that we get the desired
-    // results in the print statement below.
-    while (n < 1000) : ??? {
-        // Print the current number
-        std.debug.print("{} ", .{n});
-    }
-
-    // As in the last exercise, we want this to result in "n=1024"
-    std.debug.print("n={}\n", .{n});
+pub fn main() void{
+  var n: u32 = 2;
+  
+  // Please set the continue expression so that we get the desired
+  // results in the print statement below.
+  while(n < 1000) : (n *= 2){
+    // Print the current number
+    std.debug.print("{} ", .{n});
+  }
+  
+  // As in the last exercise, we want this to result in "n=1024"
+  std.debug.print("n={}\n", .{n});
 }
+