Created
March 18, 2018 16:57
-
-
Save Fhernd/6b198aaf861ea825971112f252b2337a to your computer and use it in GitHub Desktop.
OrtizOL. Suma recursiva en Python usando extracción de elementos de una colección. Python.
This file contains 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 sumar(operandos): | |
operando1, *operandos_restantes = operandos | |
return operando1 + sumar(operandos_restantes) if operandos_restantes else operando1 | |
operandos = [2, 3, 5, 7, 11, 13] | |
print(sumar(operandos)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment