.15 Looping with 'until'


#1

How does this continue failing? The answer is printing out the numbers 50 to 1 but says Im still not printing out numbers 50 to 1.

i = 50
until i == 0 do
print i
i -= 1
end


#2

This code should work. Make sure they want the print method and not the puts method.


#3

The codes work. I have tried it.


#4

I tried it as well and its not working for me


#5

It needs to be until i = 1. It says the numbers 1-50 not 0-50. I made the same mistake and it took my like a half hour to figure it out. So anal this thing is..


#6

No, if you replace i == 0 with i == 1, you'll only print from 50 to 2.


#7

No. I just did the code.


#8

Then it's not the same code as @jimijack's, because if you apply i == 1 to his code, it won't print all values.


#9
Imgur

and

Imgur

#10

I had the same issue but I had to comment out the prior code that it put down to make it work. Seems to only want to process the "until" loop


#11

I think it is not perfect answer, but error has been gone when I did:
i = 1
until i == 51 do
print i
i += 1
end


#12

I have this:

i = 50
while i > 1 do
print i
i += 1
end

Yet, I get the following error:
The program took too long to finish. Check your code for infinite loops and try again.

Can anyone help?


#13

Remember that the exercise wants you to count up from 1 to 50 inclusive. The following code worked for me:

i = 1
until i == 51 do
print i
i += 1
end


#14

Folks! here is what I did and worked for me.
i = 1
until i > 50 do
print i
i += 1
end

So, the approach of making i == 51 works but somewhat does not do justice to the question. The asks 1 to 50 inclusive.


#15

First you have to remove the previous codes

i = 1
while i < 51 do
print i
i += 1
end

then you have to make the new codes as below

i = 1
until i == 51 do
print i
i += 1
end


#16

i=1
until i == 51 do
print i
i += 1
end

This is correct because you are including 50 but not exceeding 51 which satisfies the exercise.


#17

This is what worked for me.
i = 1
while i <= 50 do
print i
i += 1
end


#18

Correction I use while in my previous post the until iterator is what I wanted to post. see below;
i = 1
until i == 51 do
print i
i += 1
end


#19

Thank you. I was killing myself trying to figure out what was wrong with my code (which was nothing) for ages before I deleted the previous code. Worked flawlessly. Great advice, 10/10, would heed again.


#20

I did that as well to pass the exercise.