[Next] [Prev] [Right] [Left] [Up] [Index] [Root]
Arithmetic Functions
Arithmetic Functions
CarmichaelLambda(n) : RngIntElt -> RngIntElt
The Carmichael function lambda(n); its value equals
the exponent of znstar.
FactoredCarmichaelLambda(n) : RngIntElt -> RngIntEltFact
The Carmichael function lambda(n), returned as a factorization sequence.
DivisorSigma(i, n) : RngIntElt, RngIntElt -> RngIntElt
The divisor function sigma_i(n), which equals the sum of all the d^i for d
dividing n,
for integer n and small non-negative integer i.
NumberOfDivisors(n) : RngIntElt -> RngIntElt
The number of divisors of the positive integer n. This is a special
case of DivisorSigma.
SumOfDivisors(n) : RngIntElt -> RngIntElt
The sum of the divisors of the positive integer n. This is a special
case of DivisorSigma.
EulerPhi(n) : RngIntElt -> RngIntElt
The Euler totient function phi(n); its value equals the order
of znstar.
EulerPhi(n) : RngIntElt -> RngIntElt
The Euler totient function phi(n); its value equals the order
of znstar.
FactoredEulerPhi(n) : RngIntElt -> RngIntEltFact
The Euler totient function phi(n), returned as a factorization sequence.
LegendreSymbol(n, m) : RngIntElt, RngIntElt -> RngIntElt
The Legendre symbol ((n/m)): for prime m this checks
whether or not n is a quadratic residue modulo m. The function
returns 0 if m divides n, -1 if n is not a quadratic
residue, and 1 if n is a quadratic residue modulo m. A fast probabilistic
primality test is performed on m. If m fails the test (and is therefore
composite), an error results; if it passes the test the Jacobi symbol is
computed.
JacobiSymbol(n, m) : RngIntElt, RngIntElt -> RngIntElt
The Jacobi symbol ((n/m)). For odd m > 1 this
is defined (but not calculated!) as the product of the Legendre
symbols ((n/p_i)), where the product is over all
primes p_i dividing m (including multiplicities).
Quadratic reciprocity is used to calculate this symbol, which returns
-1, 0 or 1.
KroneckerSymbol(n, m) : RngIntElt, RngIntElt -> RngIntElt
The Kronecker symbol ((n/m)). This is the extension
of the Jacobi symbol to all integers m, by multiplicativity, and by defining
((n/2))=( - 1)^((n^2 - 1)/8) for odd n (and 0 for
even n) and ((n/- 1))
equals plus or minus 1
according to the sign of n for n != 0 (and 1 for n = 0).
MoebiusMu(n) : RngIntElt -> RngIntElt
The Möbius function mu(n). This is a multiplicative function
characterized by mu(1)=1, mu(p)= - 1, and mu(p^k)=0 for k >= 2,
where p is a prime number.
Example RngInt_Amicable (H24E4)
A pair of positive integers (m, n) is called amicable if
the sum of the proper divisors (that is: excluding m itself) of
m equals n, and vice versa. The following function finds such pairs.
Note that it also finds perfect numbers: amicable pairs of the form (m, m).
> d := func< m | DivisorSigma(1, m)-m >;
> z := func< m | d(d(m)) eq m >;
> for m := 2 to 10000 do
> if z(m) then
> print m, d(m);
> end if;
> end for;
6 6
28 28
220 284
284 220
496 496
1184 1210
1210 1184
2620 2924
2924 2620
5020 5564
5564 5020
6232 6368
6368 6232
8128 8128
[Next] [Prev] [Right] [Left] [Up] [Index] [Root]