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<2>> 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++) {
- b[k] += decimal<2>(pow(-1, k - i)) *
- (decimal<2>(mass[i]) /
- decimal<2>((fact(i) * fact(k - i) * pow(3, k))));
- }
- }
- for (auto& it : b)
- cout << it << endl;
- return 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement