Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created March 18, 2018 16:57
Show Gist options
  • Save Fhernd/6b198aaf861ea825971112f252b2337a to your computer and use it in GitHub Desktop.
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.
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