39 std::cerr <<
"Usage: bounds [options]" << std::endl
41 <<
"Options:" << std::endl
42 <<
" --first n first odd number to check (1 by default)" << std::endl
43 <<
" --last n last odd number to check (101 by default)" << std::endl
44 <<
" --nb n number of odd numbers to check" << std::endl;
56 main(
int argc,
const char*
const argv[]) {
70 for (
unsigned int i = 1; i < static_cast<unsigned int>(argc); ++i) {
71 const std::string param(argv[i]);
73 if (param ==
"--first") {
79 else if (param ==
"--last") {
85 else if (param ==
"--nb") {
99 std::cout <<
"First: " << first
100 <<
"\tLast: " << last
101 <<
"\tNb: " << (first <= last
102 ? (last - first)/2 + 1
108 std::cout << std::endl
109 <<
"n\tsigma_odd\tvarsigma_odd\tUpper bound\tDeTemple\tDeTemple adapt\tSum_odd\tPow9_8\tSqrt8\tHalf_sqrt8" 130 const std::pair<sigmaodd::nat_type, unsigned int>
131 result_alpha = (prime != 1
133 : std::make_pair(n, 0u));
136 bound_DeTemple_adapt = 1;
145 bound_DeTemple_adapt = 0;
151 n_divided = result_alpha.first;
152 alpha = result_alpha.second;
165 bound_DeTemple_adapt = 0;
174 * static_cast<double>(n)));
177 * static_cast<double>(n) / 2));
180 <<
'\t' << sum_odd_divisors
181 <<
'\t' << varsum_odd_divisors
183 <<
'\t' << bound_DeTemple
184 <<
'\t' << ((bound_DeTemple_adapt > 0)
190 <<
'\t' << half_sqrt8
193 assert(varsum_odd_divisors <= sum_odd_divisors);
195 assert(sum_odd_divisors <= bound);
196 assert(sum_odd_divisors <= bound_DeTemple);
197 if (bound_DeTemple_adapt > 0) {
199 assert(varsum_odd_divisors <= bound_DeTemple_adapt);
201 assert(sum_odd_divisors <= pow9_8);
203 assert(sum_odd_divisors <= sqrt8);
206 assert(varsum_odd_divisors <= half_sqrt8);
209 assert(bound <= bound_DeTemple);
210 assert(bound_DeTemple <= sum_odd);
211 assert(bound_DeTemple_adapt <= sum_odd);
213 assert(sqrt8 <= pow9_8);
214 assert(half_sqrt8 <= sqrt8);
Define type and some generic functions.
constexpr nat_type sum_geometric_progression(nat_type r, unsigned int k)
Return the sum of the (k + 1) terms of the geometric progression of the common ratio r...
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.
constexpr bool is_odd(nat_type n)
Return true iff n is odd.
const std::string prime_filename
Default filename for the binary file "big_data/prime28.bin".
bool is_prime(nat_type n)
Return true iff n is a prime number.
nat_type divide_until_odd(nat_type n)
Return n divided by 2 until the result is odd.
constexpr bool is_even(nat_type n)
Return true iff n is even.
nat_type first_divisor(nat_type n)
Return the first divisor of n > 1 (or 1 if n <= 1)
bool is_square(nat_type n)
Return true iff n is a perfect square.
bool read_primes_table()
Read the binary file prime_filename to fill the table with all primes < 2^28. This table must be read...
Functions to access to tables of precaculated prime numbers and offsets to iterate on possible prime ...
nat_type sum_odd_divisors__factorize(nat_type n)
Calculates the sum of odd divisors of n by the factorization method and returns it.
int main(int argc, const char *const argv[])
nat_type sum_odd_divisors_upper_bound(nat_type n)
Return an upper bound of sum odd divisors.
Some generic helper functions for programs.
void print_intern_config_compiler()
Print to stdcout the intern configuration of the compiler.
Main functions to deal the sigma_odd problem.
unsigned long get_ulong(int argc, const char *const argv[], unsigned int i, void(*help_and_exit_function)())
Return argv[i] converted in integer.
std::pair< nat_type, unsigned int > divide_until_nb(nat_type n, nat_type d)
Divide n by d until the result is not divisible by d, and return (result, number of divisions)...
std::string to_string(bool b)
Return the string "true" if b, else "false".
constexpr nat_type sum_odd(nat_type n)
Return 1 + 3 + 5 + 7 + ... + (n or n-1) = k^2 with k floor((n+1)/2).
nat_type sum_odd_divisors_upper_bound__DeTemple(nat_type n)
Return an upper bound of sum odd divisors of n using the DeTemple inequalities.