Prime numbers which contain 123: Difference between revisions

→‎{{header|J}}: brief explanation
(J)
(→‎{{header|J}}: brief explanation)
Line 447:
+/1 2 3 +./@E."1/ 10 #.inv p:i.p:inv 1e6 NB. count of primes less than 1e6 containing decimal digit sequence 1 2 3
451</lang>
 
<code>p:inv 1e5</code> is 9592 -- the number of primes less than 1e5. <code>p:i.9592</code> enumerates those primes (first is 2, last is 99991). <code>10 #.inv</code> converts this to the corresponding table of decimal digits (<code>0 0 0 0 2</code> for the first row, <code>9 9 9 9 1</code> for the last row). <code>1 2 3 +./@E."1 </code> identifies those rows containing the sequence <code>1 2 3</code>, and <code>I.</code> gets the indices of those rows and, finally, <code>p:</code> gets the prime numbers corresponding to those indices. Similarly, <code>+/</code> counts the rows with suitable primes.
 
=={{header|jq}}==
{{works with|jq}}
6,962

edits