Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<bits/stdc++.h>
- #define ll long long
- using namespace std;
- void equation (int x, int n)
- {
- int sum=0;
- if (x== 0 ) cout<<-1;
- else{
- for(int i=2 ; i<=n ; i+=2){
- sum+=pow(x, i);
- }
- cout<<sum;
- }
- }
- int main() {
- ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
- int x,n;
- cin>>x>>n;
- equation(x,n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement