Skip to content

Instantly share code, notes, and snippets.

@rodrigovidal
Created November 14, 2011 05:55
Show Gist options
  • Save rodrigovidal/1363351 to your computer and use it in GitHub Desktop.
Save rodrigovidal/1363351 to your computer and use it in GitHub Desktop.
Somar funcional
public int SumNumbers(int from, int to)
{
return from > to ? 0 : (SumNumbers(from + 1, to) + from) ;
}
@iboB
Copy link

iboB commented Nov 14, 2011

what happened to good old
return ((from + to)*(to - from + 1))/2;

@rodrigovidal
Copy link
Author

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