//Gaura Deshmukh //Implementation of second Bernoulli numbers Bn by Akiyama–Tanigawa algorithm #ifndef BERNAULLI_HPP #define BERNAULLI_HPP #include #include using boost::multiprecision::cpp_dec_float_50; cpp_dec_float_50 bernoulli(int n) { if(n>1&&n&1) return 0; std::vector arr; for(int i=0;i<=n;i++) { arr.push_back(cpp_dec_float_50(1)/cpp_dec_float_50(i+1)); for(int j=i;j>=1;j--) { arr[j-1] = cpp_dec_float_50(j)*(arr[j-1]-arr[j]); } } return arr[0]; } #endif