Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <iomanip>
- #include <iostream>
- #include <string>
- #include <vector>
- #include "decimal_for_cpp/include/decimal.h"
- using namespace std;
- using namespace dec;
- int fact(int N) {
- if (N < 0)
- return 0;
- if (N == 0)
- return 1;
- else
- return N * fact(N - 1);
- }
- vector<decimal<10>> b(7);
- vector<int> mass = {9, 36, 81, 144, 225, 324, 441};
- int main() {
- for (int k = 0; k < 7; k++) {
- for (int i = 0; i <= k; i++) {
- decimal<2> first(pow(-1, k - i));
- decimal<2> second(mass[i]);
- decimal<2> third(fact(i));
- decimal<2> fourth(fact(k - i));
- decimal<2> fiveth(pow(3, k));
- b[k] += first * (second / (third * fourth * fiveth));
- }
- }
- for (auto& it : b)
- cout << it << endl;
- return 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement