Created
July 30, 2016 11:10
-
-
Save hpcslag/b2f7581033fd198a4b3741f5d59253e0 to your computer and use it in GitHub Desktop.
一個加總,各表自述
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sum(number) { | |
return (1 + number) * number / 2; | |
} | |
sum(1000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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