39 std::cerr <<
"Usage: varsigmaoddprob [options]" << std::endl
41 <<
"Method options to calculate sum of divisors:" << std::endl
42 <<
" --bound factorize method with bound shortcuts (by default)" << std::endl
43 <<
" --factorize factorize number with partial prime numbers table" << std::endl
44 <<
" --naive try each odd possible divisor)" << std::endl
46 <<
"Options:" << std::endl
47 <<
" --dot print DOT graph instead normal data" << std::endl
48 <<
" --dot-circular print DOT graph instead normal data" << std::endl
49 <<
" --first n first odd number to check (3 by default)" << std::endl
50 <<
" --last n last odd number to check (101 by default)" << std::endl
51 <<
" --nb n number of odd numbers to check" << std::endl
52 <<
" --only-longer print number with length greater than 1 (not for all options)" << std::endl
53 <<
" --path print path for each number checked" << std::endl
54 <<
" --print-long print all number that require more than 1 iteration" << std::endl
55 <<
" --print-sqr print all square numbers" << std::endl
56 <<
" --graph-point print points instead nodes (only for graph)" << std::endl
57 <<
" --graph-shortcut print shortcut graph (only for graph)" << std::endl;
69 main(
int argc,
const char*
const argv[]) {
80 const std::string method_strings[5] = {
"factorize",
89 bool dot_circular =
false;
90 bool graph_point =
false;
91 bool graph_shortcut =
false;
93 bool print_dot =
false;
94 bool print_only_longer =
false;
99 for (
unsigned int i = 1; i < static_cast<unsigned int>(argc); ++i) {
100 const std::string param(argv[i]);
102 if (param ==
"--dot") {
104 dot_circular =
false;
106 else if (param ==
"--dot-circular") {
110 else if (param ==
"--bound") {
111 method = factorize_bound;
113 else if (param ==
"--factorize") {
116 else if (param ==
"--first") {
122 else if (param ==
"--graph-point") {
125 else if (param ==
"--graph-shortcut") {
126 graph_shortcut =
true;
128 else if (param ==
"--last") {
134 else if (param ==
"--naive") {
137 else if (param ==
"--nb") {
140 else if (param ==
"--only-longer") {
141 print_only_longer =
true;
143 else if (param ==
"--path") {
146 else if (param ==
"--print-long") {
149 else if (param ==
"--print-sqr") {
158 ? (last - first)/2 + 1
166 std::cout <<
"First: " << first
167 <<
"\tLast: " << last
169 if ((method !=
print_long) && (method != print_sqr)) {
173 <<
"\tMethod: " << method_strings[method]
177 std::cout << std::endl
179 if ((method !=
print_long) && (method != print_sqr)) {
180 std::cout <<
"\tLength";
183 std::cout <<
"\tPath";
185 std::cout << std::endl;
191 const std::chrono::steady_clock::time_point clock_start = std::chrono::steady_clock::now();
199 else if (method == factorize_bound) {
202 else if (method == naive) {
208 else if (method == print_sqr) {
219 std::chrono::duration<double> duration = std::chrono::steady_clock::now() - clock_start;
uint64_t nat_type
Type for natural number used in all code, on 64 bits.
const std::string prime_filename
Default filename for the binary file "big_data/prime28.bin".
void print_sigmaodd__naive(nat_type first, nat_type last, bool print_only_longer, bool print_path)
Iterate from first to last (included) and print result of the sum_odd_divisors_divided_until_odd_iter...
constexpr bool is_even(nat_type n)
Return true iff n is even.
void print_sigmaodd__factorize_bound(nat_type first, nat_type last, bool print_only_longer, bool print_path)
Iterate from first to last (included) and print result of the sum_odd_divisors_divided_until_odd_iter...
std::string duration_to_string(std::chrono::duration< double > duration_second)
Return a string with the duration expressed in milliseconds, seconds, minutes and hours...
bool read_primes_table()
Read the binary file prime_filename to fill the table with all primes < 2^28. This table must be read...
void print_square(nat_type first, nat_type last, bool print_path)
To produce graph DOT file.
Functions to access to tables of precaculated prime numbers and offsets to iterate on possible prime ...
void print_varsigmaodd_dot(nat_type first, nat_type last, bool show_node, bool shortcut, bool circular)
Print to std::cout in a DOT format, a graph of path of the sigma odd problem.
void print_long(nat_type first, nat_type last, bool print_path)
Iterate from first to last (included) and for each odd n not square such that is_little_mersenne_prim...
std::vector< FactorExp > factorize(nat_type n)
Return a list of prime factors with their exponents.
Some generic helper functions for programs.
void print_sigmaodd__factorize(nat_type first, nat_type last, bool print_only_longer, bool print_path)
Iterate from first to last (included) and print result of the sum_odd_divisors_divided_until_odd_iter...
void print_path(const std::vector< nat_type > &path, std::ostream &out)
Send to the stream a string representation of the path. All numbers are separated by the correspondin...
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::string to_string(bool b)
Return the string "true" if b, else "false".
int main(int argc, const char *const argv[])