Skip to content

Instantly share code, notes, and snippets.

@renatoargh
Created July 23, 2012 14:50
Show Gist options
  • Select an option

  • Save renatoargh/3164029 to your computer and use it in GitHub Desktop.

Select an option

Save renatoargh/3164029 to your computer and use it in GitHub Desktop.
function somatorio(inicio, final, funcao){
if(!funcao)
funcao = function(i) { return i; };
var acumulador = 0;
for(i = inicio; i <= final; i++){
acumulador += funcao(i, acumulador);
}
return acumulador;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment