Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def sum_with_while(min, max)
- # CONSTRAINT: you should use a while..end structure
- array = (min..max).to_a
- sum = 0
- count = 0
- if min > max
- return -1
- else
- while count < array.length
- sum += array[count]
- count += 1
- end
- end
- return sum
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement