Sieve of Pritchard: Difference between revisions

m
syntax highlighting fixup automation
(→‎{{header|C#|CSharp}}: I tested it to 10000, but the task only wants 150)
m (syntax highlighting fixup automation)
Line 29:
=={{header|C#|CSharp}}==
Loosely based on the Python version. I cut a couple of things out and it still worked. Not too crazy about having to create temporary lists to add or remove from the HashSet, seems inefficient. But that is the work-around I employed, since HashSets can't be accessed by indexing. I haven't yet directly tested this against a Sieve of Eratosthenes to compare performance.
<syntaxhighlight lang="csharp">using System;
using System.Collections.Generic;
 
Line 72:
 
=={{header|J}}==
Implementation:<syntaxhighlight lang=J"j">pritchard=: {{
spokes=. $.,1
primes=. i.0
Line 88:
}}</syntaxhighlight>
 
Task example:<syntaxhighlight lang=J"j"> pritchard 150
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149</syntaxhighlight>
 
=={{header|Julia}}==
{{trans|Raku}}
<syntaxhighlight lang="julia">""" Rosetta Code task rosettacode.org/wiki/Sieve_of_Pritchard """
 
""" Pritchard sieve of primes up to limit, uses limit for type of the primes """
Line 137:
=={{header|Python}}==
{{trans|Julia}}
<syntaxhighlight lang="python">
""" Rosetta Code task rosettacode.org/wiki/Sieve_of_Pritchard """
 
Line 174:
=={{header|Raku}}==
First, a direct translation of the implementation in the YouTube video:
<syntaxhighlight lang="raku" line>unit sub MAIN($limit = 150);
 
my $maxS = 1;
Line 247:
Then a slightly more Raku-ish implementation based on the description in the Wikipedia article:
 
<syntaxhighlight lang="raku" line>unit sub MAIN($limit = 150);
 
class Wheel {
Line 294:
{{libheader|Wren-sort}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascript">import "./sort" for SortedList
import "./fmt" for Fmt
 
10,333

edits