Primes: Difference between revisions

From NARS2000
Jump to navigationJump to search
No edit summary
No edit summary
Line 48: Line 48:
       <td></td>
       <td></td>
       <td></td>
       <td></td>
       <td>returns an integer scalar whose value depends upon which number-theoretic function is chosen by <apll>L</apll> to be applied to <apll>R</apll>.</td>
       <td>returns an array whose values depend upon which number-theoretic function chosen by <apll>L</apll> is applied to <apll>R</apll>.</td>
     </tr>
     </tr>
     </table>
     </table>
Line 104: Line 104:
</tr>
</tr>
<tr>
<tr>
   <td><apll>R</apll> is a scalar consisting of a positive integer to which one of the above functions is applied.</td>
   <td><apll>R</apll> is an array consisting of positive integers to which one of the above functions is applied, element by element.</td>
</tr>
</tr>
<tr>
<tr>
   <td><apll>Z</apll> is an integer.</td>
   <td><apll>Z</apll> is an integer array of the same shape as <apll>R</apll>.</td>
</tr>
</tr>
</table>
</table>
Line 115: Line 115:


<p>The Nth prime function (<apll>¯2πR</apll>) returns the <apll>R</apll><sup>th</sup> prime where <apll>2</apll> is the first prime.  This function is sensitive to the index origin.</p>
<p>The Nth prime function (<apll>¯2πR</apll>) returns the <apll>R</apll><sup>th</sup> prime where <apll>2</apll> is the first prime.  This function is sensitive to the index origin.</p>
<p>For example, how many primes are less then or equal to <apll>1000003</apll>?</p>
<apll>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¯2π1000003<br />
15485927</apll>


== Previous Prime Function ==
== Previous Prime Function ==


<p>The previous prime function (<apll>¯1πR</apll>) returns the prime that immediately precedes <apll>R</apll>.</p>
<p>The previous prime function (<apll>¯1πR</apll>) returns the prime that immediately precedes <apll>R</apll>.</p>
<p>For example, what is the prime that immediately precedes <apll>1000000</apll>?</p>
<apll>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¯1π1000000<br />
999983</apll>


== Primality Test ==
== Primality Test ==


<p>The primality test function (<apll>0πR</apll>) returns a <apll>1</apll> if <apll>R</apll> is a prime and <apll>0</apll> if not.</p>
<p>The primality test function (<apll>0πR</apll>) returns a <apll>1</apll> if <apll>R</apll> is a prime and <apll>0</apll> if not.</p>
<p>For example, is <apll>1000003</apll> a prime?</p>
<apll>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0π1000003<br />
1</apll>


== Next Prime Function ==
== Next Prime Function ==


<p>The next prime function (<apll>1πR</apll>) returns the prime that immediately follows <apll>R</apll>.</p>
<p>The next prime function (<apll>1πR</apll>) returns the prime that immediately follows <apll>R</apll>.</p>
<p>For example, what is the next prime after <apll>1000000</apll>?</p>
<apll>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1π1000000<br />
1000003</apll>


== Number Of Primes Function ==
== Number Of Primes Function ==


<p>The number of primes function (<apll>2πR</apll>) returns number of primes less than or equal to <apll>R</apll>.</p>
<p>The number of primes function (<apll>2πR</apll>) returns number of primes less than or equal to <apll>R</apll>.</p>
<p>For example, what is the <apll>15485927</apll>th prime?</p>
<apll>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2π15485927<br />
1000003</apll>


== Divisor Count Function ==
== Divisor Count Function ==

Revision as of 15:55, 8 March 2013

Z←πR returns an integer vector consisting of the prime factors of R.
R is a scalar or one-element vector consisting of a positive integer to be factored.
Z is an integer vector whose values are the prime factors of R.


For example,

      π120
2 2 2 3 5

      ×/⎕←π⎕←¯1+2*62
4611686018427387903
3 715827883 2147483647
4611686018427387903

      π¯1+2*61
2305843009213693951

      ⍴π1
0



Z←LπR returns an array whose values depend upon which number-theoretic function chosen by L is applied to R.
L is an integer scalar whose meaning is as follows
¯2   Nth prime function
¯1   Previous prime function
 0   Primality test function
 1   Next prime function
 2   Number of primes function
10   Divisor count function
11   Divisor sum function
12   Möbius function function
13   Euler totient function
R is an array consisting of positive integers to which one of the above functions is applied, element by element.
Z is an integer array of the same shape as R.


Nth Prime Function

The Nth prime function (¯2πR) returns the Rth prime where 2 is the first prime. This function is sensitive to the index origin.

For example, how many primes are less then or equal to 1000003?

      ¯2π1000003
15485927

Previous Prime Function

The previous prime function (¯1πR) returns the prime that immediately precedes R.

For example, what is the prime that immediately precedes 1000000?

      ¯1π1000000
999983

Primality Test

The primality test function (0πR) returns a 1 if R is a prime and 0 if not.

For example, is 1000003 a prime?

      0π1000003
1

Next Prime Function

The next prime function (1πR) returns the prime that immediately follows R.

For example, what is the next prime after 1000000?

      1π1000000
1000003

Number Of Primes Function

The number of primes function (2πR) returns number of primes less than or equal to R.

For example, what is the 15485927th prime?

      2π15485927
1000003

Divisor Count Function

The divisor count function (10πR) returns the number of divisors of a number. It is the same as ×/1+∪⍦πR where πR returns the prime factors of R and ∪⍦ counts the number of occurrences of unique elements (in this case, the exponent vector of the unique primes). A divisor then consists of the product of zero or more of the unique primes which is why ×/1+ counts them.

Divisor Sum Function

The divisor sum function (11πR) returns the sum of the divisors of a number. It is the same as ×/(¯1+(∪f)*1+∪⍦f)÷¯1+∪f←πR1. This function is used to recognize deficient, perfect, and abundant numbers.

Möbius Function

The Möbius function (12πR) returns information about the square free properties of R. If R is square free, the function returns 1 if R has an even number of prime factors, and ¯1 if it has an odd number of prime factors. If the argument is not square free, the function returns 0. It is used in the Möbius Inversion Formula to invert general arithmetic functions.

Totient Function

The totient function (13πR) (also called Euler's Totient Function) returns the number of positive integers less than or equal to R that are relatively prime to it (i.e., having no common positive factors other than 1).

Notes

1 Formula for sum of divisors