Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # print from 1 to 50 (inclusive) using loops
- # 1. while loop
- i = 1
- while i < 51
- print i
- i+=1
- end
- # 2. using until keyword
- i = 1
- until i == 51 do
- print i
- i+=1
- end
- # 3. for loop with dots
- # 2 dots indicate to include the highest no. in the range. 3 dots mean go up to but DON'T include the highest no.
- for i in 1..50
- print i
- i+=1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement