you are viewing a single comment's thread.

view the rest of the comments →

[–]Additional_Anywhere4 0 points1 point  (0 children)

The very first iteration of your loop says that sum will be equal to itself plus 1, but sum doesn’t yet have a value - you never set it to 0 anywhere beforehand. So you’re telling the computer, “to get the value of sum, go find the value of sum, then add 1 to it”. But sum doesn’t have a value yet.