Created
November 14, 2011 05:55
-
-
Save rodrigovidal/1363351 to your computer and use it in GitHub Desktop.
Somar funcional
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
public int SumNumbers(int from, int to) | |
{ | |
return from > to ? 0 : (SumNumbers(from + 1, to) + from) ; | |
} |
It isn't production code. It is to demonstrate a concept.
Thanks anyway :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what happened to good old
return ((from + to)*(to - from + 1))/2;