简体   繁体   中英

GMP demo primes.c CMD syntax for arg fields?

I just finally got GMP to compile and am excited to start crunching some numbers. However, when I try to run the demo "primes.c" I am unable to figure out the correct syntax.

Every time I've run the program I get the below output

"usage: ./primes [-c] [-p] [-g] [from [+]]to"

I have devolved into just experimentally trying different iterations of this command and cannot get it to work properly.

Anyone know what the c,p,g args represent? How to actually use the demo?

Thanks

I got the program to run correctly by using the following syntax:

./primes -c -p -g to 200

The [c] parameter specifies to run the prime counting function pi(x)

if (flag_count)
    printf ("Pi(interval) = %lu\n", total_primes);

The [p] parameter simply prints each of the found primes to the cmd

if (flag_print)
{
    mpz_out_str (stdout, 10, prime);
    printf ("\n");
}

The [g] parameter finds the maximum gap between found primes

if (flag_maxgap)
    printf ("max gap: %lu\n", maxgap);

Which gives the following output

.
.
.
191
193
197
199
Pi(interval) = 46
max gap: 14

Looking into the source code for primes.c doesn't have any logic for the [from [+]] parameter which makes sense as the an "Ideas" comment block specifies it still needs to be implemented.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM