Cousin primes: Difference between revisions

Content added Content deleted
(Added Arturo implementation)
(Added AppleScript.)
Line 224: Line 224:
937 941
937 941
967 971</pre>
967 971</pre>

=={{header|AppleScript}}==
<lang applescript>on sieveOfEratosthenes(limit)
script o
property numberList : {missing value}
end script
repeat with n from 2 to limit
set end of o's numberList to n
end repeat
repeat with n from 2 to (limit ^ 0.5 div 1)
if (item n of o's numberList is n) then
repeat with multiple from (n * n) to limit by n
set item multiple of o's numberList to missing value
end repeat
end if
end repeat
return o's numberList's numbers
end sieveOfEratosthenes

local primes, output, p
set primes to sieveOfEratosthenes(999)
set output to {}
repeat with p in primes
if (p - 4 is in primes) then set end of output to {p - 4, p's contents}
end repeat
return {|cousin prime pairs < 1000|:output, |count thereof|:(count output)}</lang>

{{output}}
<lang applescript>{|cousin prime pairs < 1000|:{{3, 7}, {7, 11}, {13, 17}, {19, 23}, {37, 41}, {43, 47}, {67, 71}, {79, 83}, {97, 101}, {103, 107}, {109, 113}, {127, 131}, {163, 167}, {193, 197}, {223, 227}, {229, 233}, {277, 281}, {307, 311}, {313, 317}, {349, 353}, {379, 383}, {397, 401}, {439, 443}, {457, 461}, {463, 467}, {487, 491}, {499, 503}, {613, 617}, {643, 647}, {673, 677}, {739, 743}, {757, 761}, {769, 773}, {823, 827}, {853, 857}, {859, 863}, {877, 881}, {883, 887}, {907, 911}, {937, 941}, {967, 971}}, |count thereof|:41}</lang>


=={{header|Arturo}}==
=={{header|Arturo}}==