Untitled

Anonymous
plain_text
02/18/2025 2:35 AM
360 B
15
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