If you wanted to add all numbers together from 1 to x (ex. 1+2+3+4+5...x) what is the best way? Mathmatically there are ways easier than adding them all up in order, but I am curious about the programming side. Are there better ways to do this problem besides the obvious answers of a) one loop that takes forever or b) the recursion solution?


Reply With Quote
