I am pretty new to programming so bear with me, please.
So this is the code I have right now, I would like to know how to combine the two loops in the middle without changing the function of the program.
entry = " "
while entry != "q"
print "enter a number: "
num = gets.to_i
for x in 1..num
sum = 0
end
for y in 1..x
sum = sum + y
puts sum
end
print "press any key to continue (q to quit): "
entry = gets.chomp
end
Any help would be greatly appreciated!
Thank you!
Edit:
I guess I should clarify the function of this program; the user types in a number and then it calculates the value of each arithmetic series up to and including the number that the user put in.
So it if I type in 3 the result should display like this:
1
3
6
Sorry for the confusion!