How do I do this program?

Everytime it goes through the loop it gets added 1...