fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main() {
  6. double x;
  7. int n;
  8. double S = 0;
  9.  
  10. cout << "Nhap gia tri x: ";
  11. cin >> x;
  12. cout << "Nhap gia tri n: ";
  13. cin >> n;
  14. if (n % 2 == 0) {
  15. S = 2016 * x;
  16.  
  17. for (int i = 2; i <= n; i++) {
  18. S += pow(x, i) / (i - 1);
  19. }
  20. } else {
  21. S = 0;
  22. }
  23.  
  24. cout << "Gia tri cua bieu thuc S = " << S << endl;
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5260KB
stdin
Standard input is empty
stdout
Nhap gia tri x: Nhap gia tri n: Gia tri cua bieu thuc S = 1.40164e-306