Coprime triplets: Difference between revisions

m
m (syntax highlighting fixup automation)
m (→‎{{header|Wren}}: Minor tidy)
 
(4 intermediate revisions by 2 users not shown)
Line 914:
 
Number of elements in coprime triplets = 36</pre>
 
=={{header|Quackery}}==
 
<code>coprime</code> is defined at [[Coprimes#Quackery]].
 
<syntaxhighlight lang="Quackery"> [ over find swap found not ] is unused ( [ x --> b )
' [ 1 2 ] 2
[ 1+ dup 50 < while
over -1 peek
over coprime until
over -2 peek
over coprime until
2dup unused until
join 2 again ]
drop
echo
</syntaxhighlight>
 
{{out}}
 
<pre>[ 1 2 3 5 4 7 9 8 11 13 6 17 19 10 21 23 16 15 29 14 25 27 22 31 35 12 37 41 18 43 47 20 33 49 26 45 ]</pre>
 
=={{header|Raku}}==
Line 1,069 ⟶ 1,091:
Found 36 coprime triplets
done...
</pre>
 
=={{header|RPL}}==
{{works with|HP|49g}}
≪ {2 1} → coprimes
≪ '''WHILE''' coprimes HEAD 50 < '''REPEAT'''
coprimes 1 2 SUB
1
'''DO'''
'''DO''' 1 +
'''UNTIL''' coprimes OVER POS NOT '''END'''
'''UNTIL''' DUP2 GCD {1 1} == '''END'''
'coprimes' STO+ DROP
'''END'''
coprimes TAIL REVLIST
≫ ≫ ‘<span style="color:blue">TASK</span>’ STO
{{out}}
<pre>
1: {1 2 3 5 4 7 9 8 11 13 6 17 19 10 21 23 16 15 29 14 25 27 22 31 35 12 37 41 18 43 47 20 33 49 26 45}
</pre>
 
Line 1,164 ⟶ 1,205:
{{trans|Phix}}
{{libheader|Wren-math}}
{{libheader|Wren-seq}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./math" for Int
import "./seqfmt" for LstFmt
import "/fmt" for Fmt
 
var limit = 50
Line 1,182 ⟶ 1,221:
}
System.print("Coprime triplets under %(limit):")
for (chunk in Lst.chunks(cpt, 10)) Fmt.printtprint("$2d", chunkcpt, 10)
System.print("\nFound %(cpt.count) such numbers.")</syntaxhighlight>
 
9,479

edits