-1

I got GMP to compile, 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.

What do the c,p,g args represent?
How can I actually use the demo?

Nimantha
  • 6,405
  • 6
  • 28
  • 69
MFerguson
  • 1,739
  • 9
  • 17
  • 30
  • 1
    Have you looked in [the source](https://github.com/alisw/GMP/blob/master/demos/primes.c)? What does it tell you? – Some programmer dude Aug 31 '20 at 10:02
  • 1
    Regarding the message shown, options inside `[]` are usually considered *optional*. That means you don't have to give the `-c`, `-p` or `-g` options, or the `from` value. Only mandatory argument is the `to` value. – Some programmer dude Aug 31 '20 at 10:03

1 Answers1

0

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.

MFerguson
  • 1,739
  • 9
  • 17
  • 30