Created
August 20, 2013 12:26
-
-
Save despinozac/6280720 to your computer and use it in GitHub Desktop.
Solución planteada al problema visto en clase 19/08 en escuelaweb.
This file contains hidden or 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
def cuadrado(n) | |
n*n | |
end | |
def cubo(n) | |
n*n*n | |
end | |
def cuarta(n) | |
n*n*n*n | |
end | |
def suma(fn, a,b) | |
return 0 if (a>b) | |
self.method(fn).call(a) + suma(fn,a+1,b) | |
end | |
#Solo se invoca con el nombre de la funcion y el rango a sumar. | |
puts suma(:cuadrado,1,3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment