Sequence of primorial primes: Difference between revisions

m
→‎{{header|Phix}}: simplify slightly
m (Minor edit to C++ code)
m (→‎{{header|Phix}}: simplify slightly)
Line 2,589:
=={{header|Phix}}==
{{libheader|Phix/mpfr}}
<lang Phix>include primesmpfr.e
include mpfr.e
 
constant limit = 9999
mpz {p,p1} = mpz_inits(2,1)
 
mpz p = mpz_init(1),
p1 = mpz_init()
randstate state = gmp_randinit_mt()
atom t0 = time()
integer found = 0, i
Line 2,604 ⟶ 2,598:
for i=-1 to +1 do
mpz_add_si(p1, p, i)
if mpz_probable_prime_pmpz_prime(p1,state,25) then
integer l = mpz_sizeinbase(p,10)
string ps = iff(l>20?sprintf("%d digits",l)
Line 2,615 ⟶ 2,609:
if found>=20 then exit end if
end for
{p,p1} = mpz_free({p,p1})</lang>
state = gmp_randclear(state)</lang>
{{out}}
<pre>
7,815

edits