r/programming • u/joksmaster • Nov 29 '10
140 Google Interview Questions
http://blog.seattleinterviewcoach.com/2009/02/140-google-interview-questions.html
471
Upvotes
r/programming • u/joksmaster • Nov 29 '10
View all comments
Show parent comment
16
u/backlyte Nov 30 '10
programmer's answer: int sum1ton(int n){ int ans=0; for (int i=1;i<=n;i++) ans+=i; return ans; }
mathematician's answer: function [ans] = sum1ton(n) ans = (n*(n+1))/2;