#include <iostream>
using namespace std;
int main()
{
int j = 1, t = 2, d = 2, i;
cout << "Digite la cantidad de términos a generar: " << endl;
cin >> i;
cout << "-1" << " ";
while ( j < i ) {
if (t % 2 == 0 ) {
cout << "1/" << d << " ";
t = t + 1;
}
else {
cout << d*(-1) << " ";
t = t + 1;
}
d = d * 2;
j = j + 1;
}
return 0;
}
Generar una serie del tipo: -1 + 1/2 -4 + 1/8 - 16 + 1/32 -...
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.