>>  <<  Usr  Pri  JfC  LJ  Phr  Dic  Voc  !:  Help  Dictionary

 Primes p:  0 _ _ Primes

 The result of p: i is the i-th prime. For example: ``` p: 0 2 p: i. 15 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 ``` The inverse of p: is the number of primes less than the argument, often denoted by π(n): ``` pi=: p:^:_1 pi i. 15 0 0 0 1 2 2 3 3 4 4 4 4 5 5 6 (] , pi ,: p:@pi) i.15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 0 0 0 1 2 2 3 3 4 4 4 4 5 5 6 2 2 2 3 5 5 7 7 11 11 11 11 13 13 17 y=: (2^31)-1 ] a=: pi y 105097564 ] b=: p: a 2147483647 b=y 1 ``` _4 p: y is the next prime smaller than y and is the same as <:^:(0&p:)^:_"0 >.y-1 . _1 p: y is the same as p:^:_1 y , the number of primes less than y . 0 p: y is the same as -.1 p: y . 1 p: y is 1 if and only if y is prime. 2 p: y is the same as __ q: y , a 2-row table of the prime factors and exponents in the factorization of y . 3 p: y is the same as q: y , the list of prime factors of y whose product is equal to y . 4 p: y is the next prime larger than y and is the same as >:^:(0&p:)^:_"0 <.y+1 . 5 p: y computes the totient function (Euler’s phi function) of y , the number of non-negative integers less than y relatively prime to it, the sum +/1=y+.i.y . Currently, arguments larger than 2^31 are tested to be prime according to a probabilistic algorithm (Miller-Rabin).

```   4 p: 20
23
4&p:^:(i.8) 20
20 23 29 31 37 41 43 47

_4 p: 50
47
_4&p:^:(i.8) 50
50 47 43 41 37 31 29 23

] y=: !14x
87178291200
] c=: _4 4 p:"0 y
87178291199 87178291219
1 p: ({.c)+i.1--/c
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 p: _1+2^67x
0
m=: 366384x * */ p: i.9x
1 p: 6171054912832631x + m * i.25
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

2 p: y
2 3 5 7 11 13
11 5 2 2  1  1
'p e'=: 2 p: y
*/p^e
87178291200
y
87178291200

3 p: y
2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 5 5 7 7 11 13
*/ 3 p: y
87178291200
y
87178291200
e#p
2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 5 5 7 7 11 13

5 p: y
16721510400
*/(p-1)*p^e-1
16721510400
(- ~:)&.q: y
16721510400
```

>>  <<  Usr  Pri  JfC  LJ  Phr  Dic  Voc  !:  Help  Dictionary