Sequence of primorial primes: Difference between revisions
Content added Content deleted
m (ββThe plan) |
No edit summary |
||
Line 2,520: | Line 2,520: | ||
384 |
384 |
||
457</pre> |
457</pre> |
||
=={{header|Ring}}== |
|||
<lang ring> |
|||
# Project : Sequence of primorial primes |
|||
# Date : 2018/01/06 |
|||
# Author : Gal Zsolt (~ CalmoSoft ~) |
|||
# Email : <calmosoft@gmail.com> |
|||
max = 9999 |
|||
primes = [] |
|||
str = "" |
|||
for n = 1 to max |
|||
if isprime(n) = 1 |
|||
add(primes, n) |
|||
ok |
|||
next |
|||
for n = 1 to len(primes) |
|||
sum = 1 |
|||
for m = 1 to n |
|||
sum = sum * primes[m] |
|||
next |
|||
if (isprime(sum+1) or isprime(sum-1)) = 1 |
|||
see "" + n + " " |
|||
ok |
|||
next |
|||
func isprime(num) |
|||
if (num <= 1) return 0 ok |
|||
if (num % 2 = 0) and num != 2 return 0 ok |
|||
for i = 3 to floor(num / 2) -1 step 2 |
|||
if (num % i = 0) return 0 ok |
|||
next |
|||
return 1 |
|||
</lang> |
|||
Output: |
|||
<pre> |
|||
1, 2, 3, 4, 5, 6, 11, 13, 24, 66, 68, 75, 167, 171, 172, 287, 310, 352, 384, 457 |
|||
</pre> |
|||
=={{header|Sidef}}== |
=={{header|Sidef}}== |