Untitled
unknown
plain_text
8 months ago
269 B
4
Indexable
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int n;
cin>>n; // input
double S = 0;
int i = 0;
while (i <= n) {
i++;
S += pow(-1, i + 1) * i;
}
cout << S << endl;
return 0;
}Editor is loading...
Leave a Comment