Skip to content

Instantly share code, notes, and snippets.

@hpcslag
Created July 30, 2016 11:10
Show Gist options
  • Save hpcslag/b2f7581033fd198a4b3741f5d59253e0 to your computer and use it in GitHub Desktop.
Save hpcslag/b2f7581033fd198a4b3741f5d59253e0 to your computer and use it in GitHub Desktop.
一個加總,各表自述
function sum(number) {
return (1 + number) * number / 2;
}
sum(1000);
function sum(n)
{
if(n==0) return 0;
else return n + sum(n-1);
}
sum(1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment