Triplet of three numbers: Difference between revisions

m
(Added XPL0 example.)
 
(11 intermediate revisions by 11 users not shown)
Line 8:
{{trans|Python}}
 
<langsyntaxhighlight lang="11l">V n = 6000
V p = [0B] * 6000
 
Line 20:
L.continue
E
print(f:‘{i:4}: {i - 1:4} {i + 3:4} {i + 5:4}’)</langsyntaxhighlight>
 
{{out}}
Line 74:
=={{header|Action!}}==
{{libheader|Action! Sieve of Eratosthenes}}
<langsyntaxhighlight Actionlang="action!">INCLUDE "H6:SIEVE.ACT"
 
PROC Main()
Line 91:
OD
PrintF("%E%EThere are %I triplets",count)
RETURN</langsyntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Triplet_of_three_numbers.png Screenshot from Atari 8-bit computer]
Line 107:
 
=={{header|Ada}}==
<langsyntaxhighlight Adalang="ada">with Ada.Text_Io;
 
procedure Triplets is
Line 151:
end if;
end loop;
end Triplets;</langsyntaxhighlight>
{{out}}
<pre>
Line 204:
=={{header|ALGOL 68}}==
{{libheader|ALGOL 68-primes}}
<langsyntaxhighlight lang="algol68">BEGIN # find numbers n where n-1, n+3 and n+5 are prime #
# sieve the primes up to the maximum number for the task #
PR read "primes.incl.a68" PR
Line 221:
OD;
print( ( newline, "Found ", TOSTRING n count, " triplets", newline ) )
END</langsyntaxhighlight>
{{out}}
<pre>
Line 241:
=={{header|Arturo}}==
 
<langsyntaxhighlight lang="rebol">lst: select 3..6000 'x
-> all? @[prime? x-1 prime? x+3 prime? x+5]
 
loop split.every: 10 lst 'a ->
print map a => [pad to :string & 5]</langsyntaxhighlight>
 
{{out}}
Line 256:
 
=={{header|AWK}}==
<syntaxhighlight lang="awk">
<lang AWK>
# syntax: GAWK -f TRIPLET_OF_THREE_NUMBERS.AWK
BEGIN {
Line 283:
return(1)
}
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 338:
 
=={{header|BASIC}}==
<langsyntaxhighlight lang="basic">10 DEFINT A-Z: N=6000
20 DIM P(N+5)
30 FOR I=2 TO SQR(N)
Line 346:
70 IF P(I-1) OR P(I+3) OR P(I+5) GOTO 90
80 PRINT USING "####,: ####, ####, ####,";I;I-1;I+3;I+5
90 NEXT</langsyntaxhighlight>
{{out}}
<pre style='height:50ex'> 8: 7 11 13
Line 398:
=={{header|BASIC256}}==
{{trans|FreeBASIC}}
<syntaxhighlight lang="basic256">
<lang BASIC256>
N = 6000
dim p(N+6)
Line 418:
next i
end
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 425:
 
=={{header|BCPL}}==
<langsyntaxhighlight lang="bcpl">get "libhdr"
manifest $( limit = 6000 $)
 
Line 451:
writef("%I4: %I4, %I4, %I4*N", i, i-1, i+3, i+5)
freevec(prime)
$)</langsyntaxhighlight>
{{out}}
<pre style='height:50ex'> 8: 7, 11, 13
Line 501:
 
=={{header|C}}==
<langsyntaxhighlight lang="c">#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Line 536:
free(p);
return 0;
}</langsyntaxhighlight>
{{out}}
<pre style='height:50ex'> 8: 7, 11, 13
Line 587:
=={{header|C++}}==
{{trans|C}}
<langsyntaxhighlight lang="cpp">#include <iostream>
#include <vector>
 
Line 624:
 
return 0;
}</langsyntaxhighlight>
{{out}}
<pre> 8: 7, 11, 13
Line 675:
=={{header|C#|CSharp}}==
How about some upper limits above 6000?
<langsyntaxhighlight lang="csharp">using System; using System.Collections.Generic; using System.Linq;
using T3 = System.Tuple<int, int, int>; using static System.Console;
class Program { static void Main() {
Line 696:
for (int k = s, i = j << 1; k < l; k += i) f[k] = true; }
for (; j < l; lllj = llj, llj = lj, lj = j, j += 2)
if (isPrT(lllj, lj, j)) yield return new T3(lllj, lj, j); } }</langsyntaxhighlight>
{{out}}
<pre style='height:50ex'> "N": Prime Triplet Adjacent (to previous)
Line 754:
 
=={{header|CLU}}==
<langsyntaxhighlight lang="clu">LIMIT = 6000
 
isqrt = proc (s: int) returns (int)
Line 799:
end
end
end start_up</langsyntaxhighlight>
{{out}}
<pre style='height:50ex;'> 8: 7, 11, 13
14: 13, 17, 19
38: 37, 41, 43
68: 67, 71, 73
98: 97, 101, 103
104: 103, 107, 109
194: 193, 197, 199
224: 223, 227, 229
278: 277, 281, 283
308: 307, 311, 313
458: 457, 461, 463
614: 613, 617, 619
824: 823, 827, 829
854: 853, 857, 859
878: 877, 881, 883
1088: 1087, 1091, 1093
1298: 1297, 1301, 1303
1424: 1423, 1427, 1429
1448: 1447, 1451, 1453
1484: 1483, 1487, 1489
1664: 1663, 1667, 1669
1694: 1693, 1697, 1699
1784: 1783, 1787, 1789
1868: 1867, 1871, 1873
1874: 1873, 1877, 1879
1994: 1993, 1997, 1999
2084: 2083, 2087, 2089
2138: 2137, 2141, 2143
2378: 2377, 2381, 2383
2684: 2683, 2687, 2689
2708: 2707, 2711, 2713
2798: 2797, 2801, 2803
3164: 3163, 3167, 3169
3254: 3253, 3257, 3259
3458: 3457, 3461, 3463
3464: 3463, 3467, 3469
3848: 3847, 3851, 3853
4154: 4153, 4157, 4159
4514: 4513, 4517, 4519
4784: 4783, 4787, 4789
5228: 5227, 5231, 5233
5414: 5413, 5417, 5419
5438: 5437, 5441, 5443
5648: 5647, 5651, 5653
5654: 5653, 5657, 5659
5738: 5737, 5741, 5743</pre>
 
=={{header|Comal}}==
<syntaxhighlight lang="comal">0010 lim#:=6000
0020 DIM prime#(lim#)
0030 FOR i#:=2 TO lim# DO prime#(i#):=TRUE
0040 FOR p#:=2 TO INT(SQR(lim#)) DO
0050 FOR c#:=p#^2 TO lim# STEP p# DO prime#(c#):=FALSE
0060 ENDFOR p#
0070 FOR i#:=2 TO lim#-5 DO
0080 IF prime#(i#-1) AND prime#(i#+3) AND prime#(i#+5) THEN
0090 PRINT USING "####: ####, ####, ####":i#,i#-1,i#+3,i#+5
0100 ENDIF
0110 ENDFOR i#
0120 END</syntaxhighlight>
{{out}}
<pre style='height:50ex;'> 8: 7, 11, 13
Line 849 ⟶ 910:
 
=={{header|Cowgol}}==
<langsyntaxhighlight lang="cowgol">include "cowgol.coh";
 
const LIMIT := 6000;
Line 885 ⟶ 946:
end if;
i := i + 1;
end loop;</langsyntaxhighlight>
{{out}}
<pre style='height:50ex'>8: 7, 11, 13
Line 933 ⟶ 994:
5654: 5653, 5657, 5659
5738: 5737, 5741, 5743</pre>
 
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{libheader|SysUtils,StdCtrls}}
Uses the [[Extensible_prime_generator#Delphi|Delphi Prime-Generator Object]]
 
<syntaxhighlight lang="Delphi">
 
procedure ShowTriplePrimes(Memo: TMemo);
var I: integer;
var Sieve: TPrimeSieve;
begin
Sieve:=TPrimeSieve.Create;
try
Sieve.Intialize(10000);
for I:=1 to 6000-1 do
begin
if Sieve.Flags[I-1] and
Sieve.Flags[I+3] and
Sieve.Flags[I+5] then
begin
Memo.Lines.Add(Format('%d: %d %d %d',[I,I-1,I+3,I+5]));
end;
end;
 
finally Sieve.Free; end;
end;
 
</syntaxhighlight>
{{out}}
<pre>
8: 7 11 13
14: 13 17 19
38: 37 41 43
68: 67 71 73
98: 97 101 103
104: 103 107 109
194: 193 197 199
224: 223 227 229
278: 277 281 283
308: 307 311 313
458: 457 461 463
614: 613 617 619
824: 823 827 829
854: 853 857 859
878: 877 881 883
1088: 1087 1091 1093
1298: 1297 1301 1303
1424: 1423 1427 1429
1448: 1447 1451 1453
1484: 1483 1487 1489
1664: 1663 1667 1669
1694: 1693 1697 1699
1784: 1783 1787 1789
1868: 1867 1871 1873
1874: 1873 1877 1879
1994: 1993 1997 1999
2084: 2083 2087 2089
2138: 2137 2141 2143
2378: 2377 2381 2383
2684: 2683 2687 2689
2708: 2707 2711 2713
2798: 2797 2801 2803
3164: 3163 3167 3169
3254: 3253 3257 3259
3458: 3457 3461 3463
3464: 3463 3467 3469
3848: 3847 3851 3853
4154: 4153 4157 4159
4514: 4513 4517 4519
4784: 4783 4787 4789
5228: 5227 5231 5233
5414: 5413 5417 5419
5438: 5437 5441 5443
5648: 5647 5651 5653
5654: 5653 5657 5659
5738: 5737 5741 5743
 
Elapsed Time: 96.852 ms.
</pre>
 
=={{header|EasyLang}}==
{{trans|BASIC256}}
<syntaxhighlight>
n = 6000
len p[] n + 4
for i = 2 to sqrt len p[]
if p[i] = 0
for j = i * 2 step i to len p[]
p[j] = 1
.
.
.
for i = 3 to n - 1
if p[i - 1] = 0 and p[i + 3] = 0 and p[i + 5] = 0
print i & ": " & i - 1 & " " & i + 3 & " " & i + 5
.
.
</syntaxhighlight>
 
=={{header|F_Sharp|F#}}==
This task uses [http://www.rosettacode.org/wiki/Extensible_prime_generator#The_functions Extensible Prime Generator (F#)]
<langsyntaxhighlight lang="fsharp">
// Prime triplets: Nigel Galloway. May 18th., 2021
primes32()|>Seq.takeWhile((>)6000)|>Seq.filter(fun n->isPrime(n+4)&&isPrime(n+6))|>Seq.iter((+)1>>printf "%d "); printfn ""
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 947 ⟶ 1,107:
=={{header|Factor}}==
{{works with|Factor|0.99 2021-02-05}}
<langsyntaxhighlight lang="factor">USING: combinators formatting grouping kernel math math.primes
math.statistics sequences ;
 
Line 957 ⟶ 1,117:
"..., %4d, [%4d], __, __, %4d, __, %4d, ...\n" printf ;
 
6000 4,2-gaps [ first3 [ dup 1 + ] 2dip triplet. ] each</langsyntaxhighlight>
{{out}}
<pre style="height:14em">
Line 1,010 ⟶ 1,170:
=={{header|Forth}}==
{{works with|Gforth}}
<langsyntaxhighlight lang="forth">: prime? ( n -- ? ) here + c@ 0= ;
: notprime! ( n -- ) here + 1 swap c! ;
 
Line 1,053 ⟶ 1,213:
 
6000 main
bye</langsyntaxhighlight>
 
{{out}}
Line 1,110 ⟶ 1,270:
 
=={{header|FreeBASIC}}==
<langsyntaxhighlight lang="freebasic">
Dim As Integer N = 6000
Dim As Integer p(N)
Line 1,129 ⟶ 1,289:
Next i
Sleep
</syntaxhighlight>
</lang>
<pre>
8: 7 11 13
Line 1,183 ⟶ 1,343:
{{trans|Wren}}
{{libheader|Go-rcu}}
<langsyntaxhighlight lang="go">package main
 
import (
Line 1,207 ⟶ 1,367:
}
fmt.Printf("\n%d such numbers found.\n", len(numbers))
}</langsyntaxhighlight>
 
{{out}}
Line 1,263 ⟶ 1,423:
 
=={{header|J}}==
<langsyntaxhighlight lang="j">triplet=: (1 *./@p: _1 3 5+])"0
echo (0 _1 3 5+])"0 (triplet#]) i.6000
exit ''</langsyntaxhighlight>
{{out}}
<pre style='height:50ex'> 8 7 11 13
Line 1,318 ⟶ 1,478:
'''Works with gojq, the Go implementation of jq'''
 
<langsyntaxhighlight lang="jq">def is_prime:
if . == 2 then true
else
Line 1,329 ⟶ 1,489:
end ;
 
range(3;6000) | select( all( .-1, .+3, .+5; is_prime))</langsyntaxhighlight>
{{out}}
<pre>
Line 1,342 ⟶ 1,502:
 
=={{header|Julia}}==
<langsyntaxhighlight lang="julia">using Primes
 
makesprimetriplet(n) = all(isprime, [n - 1, n + 3, n + 5])
println(" N Prime Triplet\n--------------------------")
foreach(n -> println(rpad(n, 6), [n - 1, n + 3, n + 5]), filter(makesprimetriplet, 2:6005))
</langsyntaxhighlight>{{out}}
<pre>
N Prime Triplet
Line 1,400 ⟶ 1,560:
 
=={{header|Ksh}}==
<langsyntaxhighlight lang="ksh">
#!/bin/ksh
 
Line 1,450 ⟶ 1,610:
IFS=${oldIFS}
unset arr
done</langsyntaxhighlight>
{{out}}<pre>
8: 7,11,13
Line 1,500 ⟶ 1,660:
 
=={{header|MAD}}==
<langsyntaxhighlight MADlang="mad"> NORMAL MODE IS INTEGER
BOOLEAN PRIME
DIMENSION PRIME(6005)
Line 1,524 ⟶ 1,684:
 
VECTOR VALUES FMT = $I4,3H =,3(I5)*$
END OF PROGRAM </langsyntaxhighlight>
{{out}}
<pre style='height:50ex'> 8 = 7 11 13
Line 1,574 ⟶ 1,734:
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="mathematica">Select[Range[5999], PrimeQ[# - 1] && PrimeQ[# + 3] && PrimeQ[# + 5] &]</langsyntaxhighlight>
{{out}}
<pre>{8, 14, 38, 68, 98, 104, 194, 224, 278, 308, 458, 614, 824, 854, 878, 1088, 1298, 1424, 1448, 1484, 1664, 1694, 1784, 1868, 1874, 1994, 2084, 2138, 2378, 2684, 2708, 2798, 3164, 3254, 3458, 3464, 3848, 4154, 4514, 4784, 5228, 5414, 5438, 5648, 5654, 5738}</pre>
 
=={{header|Maxima}}==
<syntaxhighlight lang="maxima">
/* Function that find the number and the triple with the property */
triplets(n):=block(
L:makelist([i-1,i+3,i+5],i,1,n),
caching:length(L),
L1:[],
for i from 1 thru caching do if map(primep,L[i])=[true,true,true] then L1:endcons(append([[i]],L[i]),L1),
L1)$
 
/* Test case */
triplets(6000);
</syntaxhighlight>
{{out}}
<pre>
[[[8],7,11,13],[[14],13,17,19],[[38],37,41,43],[[68],67,71,73],[[98],97,101,103],[[104],103,107,109],[[194],193,197,199],[[224],223,227,229],[[278],277,281,283],[[308],307,311,313],[[458],457,461,463],[[614],613,617,619],[[824],823,827,829],[[854],853,857,859],[[878],877,881,883],[[1088],1087,1091,1093],[[1298],1297,1301,1303],[[1424],1423,1427,1429],[[1448],1447,1451,1453],[[1484],1483,1487,1489],[[1664],1663,1667,1669],[[1694],1693,1697,1699],[[1784],1783,1787,1789],[[1868],1867,1871,1873],[[1874],1873,1877,1879],[[1994],1993,1997,1999],[[2084],2083,2087,2089],[[2138],2137,2141,2143],[[2378],2377,2381,2383],[[2684],2683,2687,2689],[[2708],2707,2711,2713],[[2798],2797,2801,2803],[[3164],3163,3167,3169],[[3254],3253,3257,3259],[[3458],3457,3461,3463],[[3464],3463,3467,3469],[[3848],3847,3851,3853],[[4154],4153,4157,4159],[[4514],4513,4517,4519],[[4784],4783,4787,4789],[[5228],5227,5231,5233],[[5414],5413,5417,5419],[[5438],5437,5441,5443],[[5648],5647,5651,5653],[[5654],5653,5657,5659],[[5738],5737,5741,5743]]
</pre>
 
=={{header|Nim}}==
<langsyntaxhighlight Nimlang="nim">import strformat
 
const
Line 1,605 ⟶ 1,783:
inc count
 
echo &"\nFound {count} triplets for n < {N+1}."</langsyntaxhighlight>
 
{{out}}
Line 1,660 ⟶ 1,838:
=={{header|Perl}}==
{{libheader|ntheory}}
<langsyntaxhighlight lang="perl">#!/usr/bin/perl
 
use strict;
Line 1,667 ⟶ 1,845:
 
is_prime($_ - 4) and printf "%5d" x 4 . "\n", $_ - 3, $_ - 4, $_, $_ + 2
for @{ twin_primes( 6000 ) };</langsyntaxhighlight>
{{out}}
<pre>
Line 1,719 ⟶ 1,897:
 
=={{header|Phix}}==
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #008080;">function</span> <span style="color: #000000;">trio</span><span style="color: #0000FF;">(</span><span style="color: #004080;">integer</span> <span style="color: #000000;">n</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">return</span> <span style="color: #7060A8;">sum</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">apply</span><span style="color: #0000FF;">({</span><span style="color: #000000;">n</span><span style="color: #0000FF;">-</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">n</span><span style="color: #0000FF;">+</span><span style="color: #000000;">3</span><span style="color: #0000FF;">,</span><span style="color: #000000;">n</span><span style="color: #0000FF;">+</span><span style="color: #000000;">5</span><span style="color: #0000FF;">},</span><span style="color: #7060A8;">is_prime</span><span style="color: #0000FF;">))=</span><span style="color: #000000;">3</span> <span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #004080;">sequence</span> <span style="color: #000000;">res</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">filter</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">tagset</span><span style="color: #0000FF;">(</span><span style="color: #000000;">6000</span><span style="color: #0000FF;">),</span><span style="color: #000000;">trio</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%d found: %V\n"</span><span style="color: #0000FF;">,{</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">res</span><span style="color: #0000FF;">),</span><span style="color: #7060A8;">shorten</span><span style="color: #0000FF;">(</span><span style="color: #000000;">res</span><span style="color: #0000FF;">,</span><span style="color: #008000;">""</span><span style="color: #0000FF;">,</span><span style="color: #000000;">5</span><span style="color: #0000FF;">)})</span>
<!--</langsyntaxhighlight>-->
{{out}}
<small>(assumes you can add {-1,3,5} to each number in your head easily enough)</small>
Line 1,731 ⟶ 1,909:
 
=={{header|PL/M}}==
<langsyntaxhighlight lang="plm">100H:
BDOS: PROCEDURE (FN, ARG); DECLARE FN BYTE, ARG ADDRESS; GO TO 5; END BDOS;
EXIT: PROCEDURE; CALL BDOS(0,0); END EXIT;
Line 1,791 ⟶ 1,969:
END;
CALL EXIT;
EOF</langsyntaxhighlight>
{{out}}
<pre style='height:50ex'>8: 7, 11, 13
Line 1,843 ⟶ 2,021:
=={{header|Python}}==
{{trans|FreeBASIC}}
<langsyntaxhighlight lang="python">
#!/usr/bin/python3
 
Line 1,860 ⟶ 2,038:
else:
print(i, ': ', i-1, ' ', i+3, ' ', i+5)
</syntaxhighlight>
</lang>
<pre>
Similar a la entrada de FreeBASIC.
Line 1,867 ⟶ 2,045:
 
=={{header|Quackery}}==
<langsyntaxhighlight Quackerylang="quackery"> [ 1 swap times [ i 1+ * ] ] is ! ( n --> n )
 
[ dup 2 < iff
Line 1,882 ⟶ 2,060:
else drop ]
else drop ]
echo</langsyntaxhighlight>
 
{{out}}
Line 1,892 ⟶ 2,070:
A weird combination of [[Cousin primes]] and [[Twin primes]] that are siblings, but known by their neighbor.... I shall dub these Alabama primes.
 
<syntaxhighlight lang="raku" perl6line>say "{.[0]+1}: ",$_ for grep *.all.is-prime, ^6000 .race.map: { $_-1, $_+3, $_+5 };</langsyntaxhighlight>
{{out}}
<pre>8: (7 11 13)
Line 1,942 ⟶ 2,120:
 
=={{header|REXX}}==
<langsyntaxhighlight lang="rexx">/*REXX pgm finds prime triplets: n-1, n+3, n+5 are primes, and n < some specified #.*/
parse arg hi cols . /*obtain optional argument from the CL.*/
if hi=='' | hi=="," then hi= 6000 /*Not specified? Then use the default.*/
Line 1,986 ⟶ 2,164:
end /*k*/ /* [↑] only process numbers ≤ √ J */
#= #+1; @.#= j; sq.#= j*j; !.j= 1 /*bump # of Ps; assign next P; P²; P# */
end /*j*/; return</langsyntaxhighlight>
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
Line 2,009 ⟶ 2,187:
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
load "stdlib.ring"
see "working..." + nl
Line 2,031 ⟶ 2,209:
see "Found " + row + " prime triplets" + nl
see "done..." + nl
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 2,085 ⟶ 2,263:
Found 46 prime triplets
done...
</pre>
=={{header|RPL}}==
<code>PRIM?</code> is defined at [[Primality by trial division#RPL|Primality by trial division]]:
≪ { } 1 5
7 6000 '''FOR''' j
'''IF''' j <span style="color:blue>PRIM?</span> '''THEN'''
j SWAP -
'''IF''' DUP 2 == ROT 4 == AND '''THEN'''
SWAP j 5 - + SWAP '''END'''
j '''END'''
2 '''STEP''' DROP2
≫ '<span style="color:blue>TASK</span>' STO
{{out}}
<pre>
1: { 8 14 38 68 98 104 194 224 278 308 458 614 824 854 878 1088 1298 1424 1448 1484 1664 1694 1784 1868 1874 1994 2084 2138 2378 2684 2708 2798 3164 3254 3458 3464 3848 4154 4514 4784 5228 5414 5438 5648 5654 5738 }
</pre>
Runs in 8 minutes 22 seconds on a basic HP-48G
 
=={{header|Ruby}}==
<syntaxhighlight lang="ruby">require 'prime'
 
primes = Prime.each(6000)
p primes.each_cons(3).filter_map{|p1, p2, p3| p1 + 1 if p1+4 == p2 && p1+6 == p3}
</syntaxhighlight>
{{out}}
<pre>[8, 14, 38, 68, 98, 104, 194, 224, 278, 308, 458, 614, 824, 854, 878, 1088, 1298, 1424, 1448, 1484, 1664, 1694, 1784, 1868, 1874, 1994, 2084, 2138, 2378, 2684, 2708, 2798, 3164, 3254, 3458, 3464, 3848, 4154, 4514, 4784, 5228, 5414, 5438, 5648, 5654, 5738]
</pre>
 
=={{header|Seed7}}==
<langsyntaxhighlight lang="seed7">$ include "seed7_05.s7i";
 
const func boolean: isPrime (in integer: number) is func
Line 2,122 ⟶ 2,326:
end for;
writeln("\nFound " <& count <& " triplets for n < 6000.");
end func;</langsyntaxhighlight>
{{out}}
<pre>
Line 2,178 ⟶ 2,382:
 
=={{header|Sidef}}==
<langsyntaxhighlight lang="ruby">^6000 -> grep {|n| [-1, 3, 5].all {|k| n + k -> is_prime } }.say</langsyntaxhighlight>
{{out}}
<pre>
Line 2,187 ⟶ 2,391:
=={{header|True BASIC}}==
{{trans|FreeBASIC}}
<langsyntaxhighlight lang="basic">
LET n = 6000
 
Line 2,209 ⟶ 2,413:
NEXT i
END
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 2,215 ⟶ 2,419:
</pre>
 
=={{header|V (Vlang)}}==
{{trans|Python}}
<syntaxhighlight lang="v (vlang)">import math
 
const n = 6000
 
fn main() {
mut p := []bool{len:n, init:false}
for i in 2..int(math.round(math.pow(n,.5))) {
if !p[i] {
for j:=i*2;j<n;j+=i {
p[j] = true
}
}
}
for i in 3..n {
if p[i-1] || p[i+3] || p[i+5] {
continue
}
else {
println('$i : ${i-1} ${i+3} ${i+5}')
}
}
}</syntaxhighlight>
<pre>
Similar to Go
</pre>
 
=={{header|Wren}}==
{{libheader|Wren-math}}
{{libheader|Wren-fmt}}
<langsyntaxhighlight ecmascriptlang="wren">import "./math" for Int
import "./fmt" for Fmt
 
var c = Int.primeSieve(6003, false)
Line 2,231 ⟶ 2,462:
}
for (n in numbers) Fmt.print("$,6d => $,6d", n, [n-1, n+3, n+5])
System.print("\nFound %(numbers.count) such numbers.")</langsyntaxhighlight>
 
{{out}}
Line 2,287 ⟶ 2,518:
 
=={{header|XPL0}}==
<langsyntaxhighlight XPL0lang="xpl0">func IsPrime(N); \Return 'true' if N is prime
int N, I;
[if N <= 2 then return N = 2;
Line 2,313 ⟶ 2,544:
Text(0, " prime triplets found below 6000.
");
]</langsyntaxhighlight>
 
{{out}}
Line 2,329 ⟶ 2,560:
46 prime triplets found below 6000.
</pre>
 
=={{header|Yabasic}}==
{{trans|Python}}
<syntaxhighlight lang="yabasic">// Rosetta Code problem: http://rosettacode.org/wiki/Triplet_of_three_numbers
// by Galileo, 04/2022
 
N = 6000
dim p(N)
 
for i = 2 to int(N ^ 0.5)
if not p(i) then
for j = i*2 to N step i
p(j) = 1
next
endif
next
 
for i = 3 to N
if not (p(i-1) or p(i+3) or p(i+5)) print i, ": ", i-1, " ", i+3, " ", i+5
next</syntaxhighlight>
{{out}}
<pre>8: 7 11 13
14: 13 17 19
38: 37 41 43
68: 67 71 73
98: 97 101 103
104: 103 107 109
194: 193 197 199
224: 223 227 229
278: 277 281 283
308: 307 311 313
458: 457 461 463
614: 613 617 619
824: 823 827 829
854: 853 857 859
878: 877 881 883
1088: 1087 1091 1093
1298: 1297 1301 1303
1424: 1423 1427 1429
1448: 1447 1451 1453
1484: 1483 1487 1489
1664: 1663 1667 1669
1694: 1693 1697 1699
1784: 1783 1787 1789
1868: 1867 1871 1873
1874: 1873 1877 1879
1994: 1993 1997 1999
2084: 2083 2087 2089
2138: 2137 2141 2143
2378: 2377 2381 2383
2684: 2683 2687 2689
2708: 2707 2711 2713
2798: 2797 2801 2803
3164: 3163 3167 3169
3254: 3253 3257 3259
3458: 3457 3461 3463
3464: 3463 3467 3469
3848: 3847 3851 3853
4154: 4153 4157 4159
4514: 4513 4517 4519
4784: 4783 4787 4789
5228: 5227 5231 5233
5414: 5413 5417 5419
5438: 5437 5441 5443
5648: 5647 5651 5653
5654: 5653 5657 5659
5738: 5737 5741 5743
---Program done, press RETURN---</pre>
1,983

edits