Skip to content

Instantly share code, notes, and snippets.

@despinozac
Created August 20, 2013 12:26
Show Gist options
  • Save despinozac/6280720 to your computer and use it in GitHub Desktop.
Save despinozac/6280720 to your computer and use it in GitHub Desktop.
Solución planteada al problema visto en clase 19/08 en escuelaweb.
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