How would I do this using ruby and only using a while loop with if, elsif and else only?
CodePudding user response:
sum = 0
i = 1
while i < 251
sum = i
i = 1
end
puts sum
CodePudding user response:
another way to implement this:
n = 250
while true
puts ( n * (n 1)) / 2
break
end
Or make the loop entirely a token thing
n = 250
while false
end
puts ( n * (n 1)) / 2