⍝ Prime numbers:

    pco ⎕io                 ⍝ the first prime
2
    pco 2 5⍴ ⍳10            ⍝ the first 10 primes in a 2 by 5 table
 2  3  5  7 11
13 17 19 23 29

    pco 1234567             ⍝ the 1234567-th prime
19394489

    ¯1 pco 19394509         ⍝ the number of primes < 19394509
1234567

    ¯1 pco 97               ⍝ # primes < 97
24
    ¯1 pco 97.5             ⍝ # primes < 97.5
25
    pco 24                  ⍝ the 24-th prime
89
    ¯1 pco ¯1+2*31          ⍝ # primes < ¯1+2*31
105097564

    pco 105097565           ⍝ the 105097565-th prime (counting from 1)
2147483647

    1 pco 314159            ⍝ is 314159 a prime?
1
    1 pco 113*2             ⍝ [AA]
0
    {⍵/⍳⍴⍵} 1 pco ⍳25       ⍝ all the primes less than 25
2 3 5 7 11 13 17 19 23

    0 pco 144 17 49         ⍝ which numbers are not prime?
1 0 1

    3 pco 144               ⍝ prime factorization
2 2 2 2 3 3

    2 pco 144               ⍝ primes and exponents
2 3
4 2
    ⍬ ≡ 3 pco 1             ⍝ the prime factorization of 1 is null
1
    4 pco 10*1 2 3 4        ⍝ the next prime > 10 100 ...
11 101 1009 10007
    ¯4 pco 10*1 2 3 4       ⍝ the next prime < 10 100 ...
7 97 997 9973

    b←10 pco 10 20          ⍝ primes between 10 and 20.

    b/10 to 19              ⍝ prime between 10 and 20.
11 13 17 19

⍝ Errors:

    pco 105097565+1         ⍝ too big
11::nonce error
    pco ¯2                  ⍝ too negative
11::assertion failure
    pco 1,⊂2 3              ⍝ too deep
11::assertion failure
    pco 3.4                 ⍝ unnatural number
11::assertion failure
    4 pco 3*31              ⍝ too big
11::nonce error
    ¯4 pco 2                ⍝ too small
11::assertion failure
    3 pco 66 77             ⍝ too many items
11::assertion failure

⍝∇ pco to

Back to: code

Back to: Workspaces