Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialPatrick Shushereba
10,911 PointsWhile Loop Sum
I'm trying to write a program to sum numbers, without using an array, and it's not working right. It's only giving me an output of 100.
n = 0
sum = 0
while n <= 99
n += 1
sum = n
end
puts sum
2 Answers
Abigail Glunn
10,068 PointsYw! Would really appreciate it if you'd vote it best answer... thanks! : )
Patrick Shushereba
10,911 PointsYes, incrementing sum fixed the problem. I don't know what my problem is. As I'm learning, it seems like the simple things are tripping me up. Thank you.
Abigail Glunn
10,068 PointsAbigail Glunn
10,068 PointsHey! Try it with sum +=....
Really close to what you had already! That what you were looking for?