Learn

Okay, training wheels off. Let’s see your stuff!

i = 3 while i > 0 do print i i -= 1 end
  1. In the above example, we create a variable called i and set it to 3.
  2. Then, we print out 321 since we execute the loop as long as i 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

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?