Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
f = (n) => {
var sumaConb = 0;
var c = 0;
for (var i = 0; i <= n; i++) {
var numerador = 1
var denominador = 1
for (var j = 0; j < i; j++) {
numerador *= (n - j)
denominador *= (j + 1);
c = c + 2;
}
sumaConb += numerador / denominador
c++
}
return {suma:sumaConb,c:c};
}
f1 = (n) => {
var sumaConb = 1;
var c = 0;
for (var j = 0; j < n; j++) {
sumaConb *= 2;
c = c + 2;
}
return {suma:sumaConb,c:c};
}
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].forEach(i => { console.log(i, f(i).suma, f(i).c, f1(i).suma, f1(i).c) });
[5,7,9,11,13,15,17,19,21,23,25,27].forEach(i => { console.log(i, f(i).c) });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.