16 #include "../helper/helper.hpp" 28 if (n >= 17878103347812890625ul) {
33 =
static_cast<nat_type>(std::floor(std::sqrt(std::sqrt(std::sqrt(static_cast<double>(n))))));
53 if (n >= 18445618199572250625ul) {
57 nat_type root =
static_cast<nat_type>(std::floor(std::sqrt(std::sqrt(static_cast<double>(n)))));
77 if (n >= 18446744065119617025ul) {
81 nat_type sqrt_n =
static_cast<nat_type>(floor(sqrt(static_cast<double>(n))));
84 while (
square(sqrt_n) <= n) {
89 }
while (
square(sqrt_n) > n);
91 assert(
square(sqrt_n) <= n);
92 assert(n <
square(sqrt_n + 1));
101 const std::vector<nat_type> &bad_table) {
102 std::vector<nat_type> new_bad_table =
load_numbers(filename);
104 if (!new_bad_table.empty()) {
105 new_bad_table.insert(new_bad_table.begin(), bad_table.cbegin(), bad_table.cend());
108 sort(new_bad_table.begin(), new_bad_table.end());
110 return new_bad_table;
114 std::vector<nat_type>
116 std::vector<nat_type> list;
117 std::ifstream infile(filename, std::ios::in);
119 if (infile.is_open()) {
122 while (getline(infile, line)) {
123 const auto i = line.find_first_not_of(
"0123456789");
124 const std::string s(i == std::string::npos
unsigned long nat_type
Type for natural number used in all code, on 64 bits.
nat_type floor_square_root(nat_type n)
Return the square root of n rounded to below.
uint64_t nat_type
Type for natural number used in all code, on 64 bits.
nat_type floor_eighth_root(nat_type n)
Return the eighth root of n rounded to below.
A lot of functions and stuffs to deal the sigma_odd problem and related stuffs.
nat_type floor_fourth_root(nat_type n)
Return the fourth root of n rounded to below.
Some generic helper functions for programs.
std::vector< nat_type > load_numbers(const std::string &filename)
Read the file and extract each natural number begining a line. Return the list of these numbers...
constexpr double square(double x)
Return x*x.
std::vector< nat_type > load_bad_table(const std::string &filename, const std::vector< nat_type > &bad_table)
Read a file that contains list of bad numbers, add after bad_table, and return the result...