This site is supported by donations to The OEIS Foundation.

List of number theoretic functions in Mathematica by version

From OeisWiki
Jump to: navigation, search

This article needs more work.

Please help by expanding it!



With each new version of Wolfram Mathematica, new features are added. Although it is possible that every Mathematica command has appeared at least once in the OEIS, the number theoretic functions are the most relevant and some of the most frequently used in the OEIS.

Available since version 1.0

  • Divisors[n] gives a list of the divisors of sorted in ascending order and including 1 and itself.
  • EulerPhi[n] is Euler's totient function
  • FactorInteger[n] gives a list of prime factors and exponents of , and, if necessary, a unit ( in the case of negative real integers, or in the case of imaginary integers).
  • GCD[m, n] gives the greatest common divisor of and (three or more arguments can also be used).
  • LCM[m, n] gives the least common multiple of and (three or more arguments can also be used).
  • Mod[m, n] gives the remainder in
  • MoebiusMu[n] is the Möbius function
  • Prime[n] gives the th prime number
  • PrimeQ[x] tells whether is a prime number or not.
  • Zeta[s] is the Riemann zeta function.

Added in version 2.0

  • IntegerDigits[n, b] gives a list of the base digits of (b is optional and assumed to be 10 if left off).
  • PrimePi[x] is the prime counting function

Added in version 3.0

Added in version 4.0

  • CarmichaelLambda[n] is the Carmichael function

Note that GCD and LCM were modified in this version.

Added in version 5.0

Note that PrimeQ was modified in this version.

Added in version 6.0

  • IntegerPartitions[n] lists the partitions of into smaller integers. (Note however that even smallish numbers like 100 can cause the kernel to run out of memory and quit).
  • NextPrime[x, k] is essentially a quicker way of asking Prime[PrimePi[x] + k]. (Note that k may be negative).
  • RandomPrime[{min, max}] gives a pseudorandom prime between min and max.
  • ZetaZero[k] gives the th complex number such that in the Riemann zeta function we have (this assumes that all zeta zeroes have ).

Note that FactorInteger was modified in this version.

Added in version 7.0

Added in version 8.0

Wishlist functions

When enough users define their own version of the same function, Wolfram takes notice, and might add the function in a future version. But one can't always guess at the reasoning for these decisions: you might think a function is defined easily and efficiently enough in terms of previously existing functions and it gets added, and other times a function is a little more involved to program and it doesn't get added; still other times you think it was about time the function was added.

I for one didn't see much of a need for NextPrime, but I am glad PrimeOmegan and PrimeNu were added, as I was gettng tired of constantly having to look up A001221 and A001222 each time I wanted to define bigOmega or lilOmega.

Semiprime equivalents to the prime functions would be useful additions; the OEIS contains quite a few different implementations of such functions:

semiPrimePi[x_] := Sum[PrimePi[x/Prime@i] - i + 1, {i, PrimePi@ Sqrt@n}];
semiPrime[n_Integer] := Block[{e = Floor[Log[2, n] + 1], a, b}, a = 2^e; Do[b = 2^p; While[semiPrimePi@a < n, a = a + b]; a = a - b/2, {p, e, 0, -1}]; a + b/2];
semiPrimeQ[n_Integer] := TrueQ[semiPrimePi[n] > semiPrimePi[n - 1]];
semiPrime::usage = "semiPrime[n] gives the nth semiprime."
semiPrimeQ::usage = "semiPrimeQ[n] returns True if n is a semiprime, False otherwise."
semiPrimePi::usage = "semiPrimePi[x] tells how many primes there are between 0 and x."

Or maybe the prime functions could be modified to take an argument that specifies the number of prime factors. Seen this way, PrimePi[x] is and semiPrimePi[x] is ; so PrimePi[k, x] could be .

There's perhaps not much need for palindromic testing functions as these are very easily programmed off the top of one's head.

palindromicNumberQ[n_Integer, b_:10] = TrueQ[IntegerDigits[n, b] == Reverse[IntegerDigits[n, b]]]

Definitions for use in older versions

An equivalent of NextPrime is programmed easily enough for use in Mathematica 5.2 and earlier:

nxtPrm[x_, incr_:1] := Prime[PrimePi[x] + incr]

Just as with NextPrime, this can be called with just one argument. However, this functions differently from NextPrime when incr is negative (and worse a negative argument will result in an error if whereas NextPrime will handle this more gracefully).