Y
Hacker News
new
|
ask
|
show
|
jobs
by
rramadass
1420 days ago
Example Problem: Calculate the sum of the first N natural numbers.
Declarative: N(N+1)/2
Imperative: for(int sum=0, int i=1; i<=N; i++) {sum = sum+i;}