Thursday, October 20, 2011 No. 08 - Calculate 1+2+…+n Problem: Calculate 1+2+…+n without multiplication, division, key words for, while, if, else, switch, case, as well as conditional operator (A ? B : C). Analysis: This problem is not meaningful during software development since usually we do not have such rigorous limitations. However, many interviewers believe that it is useful to test candidates’ ability of divergent thinking. Ability of divergent thinking reflects the depth and width of programming understanding. Besides equation n(n+1)/2 to get 1+2+…+n, we only have two approaches:
Read full article from Coding Interview Questions: No. 08 - Calculate 1+2+…+n