Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Somar funcional
public int SumNumbers(int from, int to)
{
return from > to ? 0 : (SumNumbers(from + 1, to) + from) ;
}
@iboB

This comment has been minimized.

Copy link

@iboB iboB commented Nov 14, 2011

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

@rodrigovidal

This comment has been minimized.

Copy link
Owner Author

@rodrigovidal rodrigovidal commented Nov 14, 2011

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
You can’t perform that action at this time.