Ormiston pairs: Difference between revisions
Content added Content deleted
(Added Go) |
(→{{header|J}}: more compact presentation) |
||
Line 238: | Line 238: | ||
For this, we would like to be able to test if a prime number is the first value in an Ormiston pair: |
For this, we would like to be able to test if a prime number is the first value in an Ormiston pair: |
||
<syntaxhighlight lang=J> isorm=: -:&(/:~)&":&> 4 p: ]</syntaxhighlight> |
<syntaxhighlight lang=J> isorm=: -:&(/:~)&":&> 4 p: ]</syntaxhighlight> |
||
We could also use a routine to organize pairs of numbers as moderate width lines of text: |
|||
<syntaxhighlight lang=J> fmtpairs=: {{ names <@([,',',])&":/"1 y}}</syntaxhighlight> |
|||
Then the task becomes: |
Then the task becomes: |
||
<syntaxhighlight lang=J> (,. 4 p:]) p:30{.I. isorm i.&.(p:inv) 1e6 |
<syntaxhighlight lang=J> fmtpairs (,. 4 p:]) p:30{.I. isorm i.&.(p:inv) 1e6 |
||
1913,1931 18379,18397 19013,19031 25013,25031 |
|||
1913 1931 |
|||
34613,34631 35617,35671 35879,35897 36979,36997 |
|||
18379 18397 |
|||
37379,37397 37813,37831 40013,40031 40213,40231 |
|||
19013 19031 |
|||
40639,40693 45613,45631 48091,48109 49279,49297 |
|||
25013 25031 |
|||
51613,51631 55313,55331 56179,56197 56713,56731 |
|||
34613 34631 |
|||
58613,58631 63079,63097 63179,63197 64091,64109 |
|||
35617 35671 |
|||
65479,65497 66413,66431 74779,74797 75913,75931 |
|||
35879 35897 |
|||
76213,76231 76579,76597 |
|||
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 |
|||
+/isorm i.&.(p:inv) 1e6 NB. number of Ormiston pairs less than 1e6 |
+/isorm i.&.(p:inv) 1e6 NB. number of Ormiston pairs less than 1e6 |
||
382 |
382 |