Learn
Okay, training wheels off. Let’s see your stuff!
i = 3 while i > 0 do print i i -= 1 end
- In the above example, we create a variable called
i
and set it to3
. - Then, we print out
321
since we execute the loop as long asi
is positive.
Instructions
1.
Use a while
loop to print
out the numbers 1 through 50, inclusive. While the example above counts down, you will want to count up.Use print
rather than puts
, and don’t forget to increment your variable.
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.