mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   YAFU (https://www.mersenneforum.org/forumdisplay.php?f=96)
-   -   nextprime() odd behavior? (https://www.mersenneforum.org/showthread.php?t=26648)

EdH 2021-03-28 02:23

nextprime() odd behavior?
 
Doesn't this seem a tiny bit odd?

Script (calling YAFU wip r395):
[code]#!/bin/bash

np=2
while [ $np -lt 30 ]
do
printf "nextprime for $np is "
np=$(./yafu "nextprime($np)" -silent)
echo "$np"
done
[/code]Result:
[code]$ bash primesgen.sh
nextprime for 2 is 3
[B]nextprime for 3 is 13[/B]
nextprime for 13 is 17
nextprime for 17 is 19
nextprime for 19 is 23
nextprime for 23 is 29
nextprime for 29 is 31
[/code]Not that anyone would generate primes in this fashion.:whistle:

bsquared 2021-03-29 14:48

Well, that was silly. Thanks as always for testing! Fixed in r396.

P.s., *cough* "primes(0,1e6,0)" -pscreen *cough* :razz:

EdH 2021-03-29 18:11

[QUOTE=bsquared;574727]Well, that was silly. Thanks as always for testing! Fixed in r396.

P.s., *cough* "primes(0,1e6,0)" -pscreen *cough* :razz:[/QUOTE]
Thanks! I remembered nextprime(), but not primes(). And, there's no way I would have remembered it needed 3 values. I'd have had to look it up.:smile:

bsquared 2021-03-29 18:18

[QUOTE=EdH;574754]Thanks! I remembered nextprime(), but not primes(). And, there's no way I would have remembered it needed 3 values. I'd have had to look it up.:smile:[/QUOTE]

I had to look it up too :smile:. primes(0,1000000) is the same as primes(0,1000000,1) which just counts primes in the range. primes(0,1000000,0) actually computes them and -pscreen dumps them to screen. -pfile puts them in primes.dat.

EdH 2021-03-29 20:19

[QUOTE=bsquared;574755]I had to look it up too :smile:. primes(0,1000000) is the same as primes(0,1000000,1) which just counts primes in the range. primes(0,1000000,0) actually computes them and -pscreen dumps them to screen. -pfile puts them in primes.dat.[/QUOTE]
I need to review the docs more often. I find lots of neat things in there!

Thanks for all!


All times are UTC. The time now is 10:21.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.