Neighbour primes: Difference between revisions
Content added Content deleted
No edit summary |
Alextretyak (talk | contribs) (Added 11l) |
||
Line 5: | Line 5: | ||
Find and show primes p such that p*q+2 is prime, where q is next prime after p and '''p < 500''' |
Find and show primes p such that p*q+2 is prime, where q is next prime after p and '''p < 500''' |
||
<br><br> |
<br><br> |
||
=={{header|11l}}== |
|||
{{trans|Python}} |
|||
<syntaxhighlight lang="11l"> |
|||
F isPrime(n) |
|||
L(i) 2 .. Int(n ^ 0.5) |
|||
I n % i == 0 |
|||
R 0B |
|||
R 1B |
|||
print(‘p q pq+2’) |
|||
print(‘-----------------------’) |
|||
L(p) 2..498 |
|||
I !isPrime(p) |
|||
L.continue |
|||
V q = p + 1 |
|||
L !isPrime(q) |
|||
q++ |
|||
I !isPrime(2 + p * q) |
|||
L.continue |
|||
print(p" \t "q" \t "(2 + p * q)) |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
p q pq+2 |
|||
----------------------- |
|||
3 5 17 |
|||
5 7 37 |
|||
7 11 79 |
|||
13 17 223 |
|||
19 23 439 |
|||
67 71 4759 |
|||
149 151 22501 |
|||
179 181 32401 |
|||
229 233 53359 |
|||
239 241 57601 |
|||
241 251 60493 |
|||
269 271 72901 |
|||
277 281 77839 |
|||
307 311 95479 |
|||
313 317 99223 |
|||
397 401 159199 |
|||
401 409 164011 |
|||
419 421 176401 |
|||
439 443 194479 |
|||
487 491 239119 |
|||
</pre> |
|||
=={{header|ALGOL W}}== |
=={{header|ALGOL W}}== |