简体   繁体   English

用于 arg 字段的 GMP 演示 primes.c CMD 语法?

[英]GMP demo primes.c CMD syntax for arg fields?

I just finally got GMP to compile and am excited to start crunching some numbers.我终于编译了 GMP,并且很高兴开始处理一些数字。 However, when I try to run the demo "primes.c" I am unable to figure out the correct syntax.但是,当我尝试运行演示“primes.c”时,我无法找出正确的语法。

Every time I've run the program I get the below output每次我运行程序时,我都会得到以下输出

"usage: ./primes [-c] [-p] [-g] [from [+]]to" “用法:./primes [-c] [-p] [-g] [从 [+]] 到”

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?有人知道 c,p,g args 代表什么吗? 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) [c] 参数指定运行素数计数函数 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 [p] 参数只是将找到的每个素数打印到 cmd

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

The [g] parameter finds the maximum gap between found primes [g] 参数找到找到的素数之间的最大差距

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.查看 primes.c 的源代码没有关于 [from [+]] 参数的任何逻辑,这是有道理的,因为“Ideas”注释块指定它仍然需要实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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