Skip to content

Instantly share code, notes, and snippets.

@thiagofm
Created October 22, 2013 22:14
Show Gist options
  • Save thiagofm/7109133 to your computer and use it in GitHub Desktop.
Save thiagofm/7109133 to your computer and use it in GitHub Desktop.
gauss.sc
object gauss {
def gauss = {
def sum(f: Int => Int, a: Int, b: Int): Int = {
if (a > b) 0
else f(a) + sum(f, a+1, b)
}
sum(x => x, 1, 100)
} //> gauss: => Int
gauss //> res0: Int = 5050
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment