Ormiston pairs: Difference between revisions
Content added Content deleted
(Added AppleScript.) |
|||
Line 1,412: | Line 1,412: | ||
382 Ormiston pairs before one million |
382 Ormiston pairs before one million |
||
3722 Ormiston pairs before ten million</pre> |
3722 Ormiston pairs before ten million</pre> |
||
=={{header|Ring}}== |
|||
<syntaxhighlight lang="ring"> |
|||
see "working..." + nl |
|||
see "First 30 Ormiston pairs:" + nl |
|||
limit = 1000000 |
|||
Primes = [] |
|||
Primes1 = [] |
|||
Primes2 = [] |
|||
add(Primes,2) |
|||
pr = 1 |
|||
while true |
|||
pr = pr + 2 |
|||
if isPrime(pr) and pr < limit |
|||
add(Primes,pr) |
|||
ok |
|||
if pr > limit |
|||
exit |
|||
ok |
|||
end |
|||
n = 0 |
|||
row = 0 |
|||
for n = 1 to len(Primes) - 1 |
|||
Primes1 = [] |
|||
Primes2 = [] |
|||
str1 = string(Primes[n]) |
|||
str2 = string(Primes[n+1]) |
|||
for p = 1 to len(str1) |
|||
add(Primes1,substr(str1,p,1)) |
|||
next |
|||
for p = 1 to len(str2) |
|||
add(Primes2,substr(str2,p,1)) |
|||
next |
|||
Sort1 = sort(Primes1) |
|||
Sort2 = sort(Primes2) |
|||
flag = 1 |
|||
if len(Sort1) = len(Sort2) |
|||
for p = 1 to len(Sort1) |
|||
if Sort1[p] != Sort2[p] |
|||
flag = 0 |
|||
exit |
|||
ok |
|||
next |
|||
if flag = 1 |
|||
row++ |
|||
if row < 31 |
|||
str1m = str1 |
|||
str2m = str2 |
|||
see "(" + str1 + ", " + str2 + ") " |
|||
if row % 3 = 0 |
|||
see nl |
|||
ok |
|||
ok |
|||
ok |
|||
ok |
|||
end |
|||
see nl + "Number of pairs < 1,000,000: " + row + nl |
|||
see "done..." + nl |
|||
func isPrime num |
|||
if (num <= 1) return 0 ok |
|||
if (num % 2 = 0 and num != 2) return 0 ok |
|||
for i = 3 to floor(num / 2) -1 step 2 |
|||
if (num % i = 0) return 0 ok |
|||
next |
|||
return 1 |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
working... |
|||
First 30 Ormiston pairs: |
|||
( 1913, 1931) (18379, 18397) (19013, 19031) |
|||
(25013, 25031) (34613, 34631) (35617, 35671) |
|||
(35879, 35897) (36979, 36997) (37379, 37397) |
|||
(37813, 37831) (40013, 40031) (40213, 40231) |
|||
(40639, 40693) (45613, 45631) (48091, 48109) |
|||
(49279, 49297) (51613, 51631) (55313, 55331) |
|||
(56179, 56197) (56713, 56731) (58613, 58631) |
|||
(63079, 63097) (63179, 63197) (64091, 64109) |
|||
(65479, 65497) (66413, 66431) (74779, 74797) |
|||
(75913, 75931) (76213, 76231) (76579, 76597) |
|||
Number of pairs < 1,000,000: 382 |
|||
done... |
|||
</pre> |
|||
=={{header|Rust}}== |
=={{header|Rust}}== |