Prime numbers p for which the sum of primes less than or equal to p is prime: Difference between revisions
Content added Content deleted
imported>Chinhouse No edit summary |
|||
Line 396: | Line 396: | ||
953 |
953 |
||
</pre> |
</pre> |
||
=={{header|MiniScript}}== |
|||
<syntaxhighlight lang="miniscript"> |
|||
isPrime = function(n) |
|||
if n <= 3 then return n > 1 |
|||
if n % 2 == 0 or n % 3 == 0 then return false |
|||
i = 5 |
|||
while i ^ 2 <= n |
|||
if n % i == 0 or n % (i + 2) == 0 then return false |
|||
i += 6 |
|||
end while |
|||
return true |
|||
end function |
|||
primes = [] |
|||
sum = 0 |
|||
for n in range(2, 1000) |
|||
if isPrime(n) then |
|||
sum += n |
|||
if isPrime(sum) then primes.push(n) |
|||
end if |
|||
end for |
|||
print primes.len + " found: " + primes |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
⚫ | |||
21 found: [2, 3, 7, 13, 37, 43, 281, 311, 503, 541, 557, 593, 619, 673, 683, 733, 743, 839, 881, 929, 953</pre> |
|||
=={{header|Nim}}== |
=={{header|Nim}}== |
||
Line 785: | Line 815: | ||
"); |
"); |
||
]</syntaxhighlight> |
]</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
⚫ | |||
⚫ | |||
⚫ | |||
557 593 619 673 683 733 743 839 881 929 |
557 593 619 673 683 733 743 839 881 929 |
||
953 |
953 |