No BSD License
-
Fibonacci(n)
Fibonacci.m by David Terr, Raytheon, 5-11-04
-
GeneralizedFibonacci(n,a,b)
GeneralizedFibonacci.m by David Terr, Raytheon, 10-20-04
-
GeneralizedLucas(n,a,b)
GeneralizedLucas.m by David Terr, Raytheon, 10-20-04
-
JacobiSymbol(a,b)
Compute the Jacobi symbol (a/b), where a and b are integers with b odd and positive.
-
Lucas(n)
Fibonacci.m by David Terr, Raytheon, 5-11-04
-
MinkowskiQM(x)
Given x from 0 to 1, compute the Minkowski question mark function of x.
-
Pell(d,s,n)
-
QCF(d,u,v,quiet)
-
RoundQCF(d,u,v,quiet)
-
binomial(n,m)
binomial.m by David Terr, Raytheon, 5-11-04
-
cfrac(x,n)
-
factor2( n )
-
fromcfrac( a )
Return the number whose continued fraction coefficieints are given as a row or column vector.
-
harmonic(z)
harmonic.m by David Terr, Raytheon, 9-10-04
-
partitiontable(n)
PartitionTable.m by David Terr, Raytheon, 6-7-04
-
qftimes(f1,f2)
qftimes.m by David Terr, Raytheon, 11-17-04
-
roundcfrac(x,n)
-
rqf(f)
-
sigma(k,n)
-
tau(n)
-
partitionplot.m
-
View all files
from
numerical.zip
by David Terr
Archive containing numerical function files.
|
| sigma(k,n)
|
% sigma by David Terr, Raytheon Inc., 5-19-04
% Given a nonnegative integers k and n, return the sum of the kth powers of
% the divisors of n. For example, sigma(1,6) = 1 + 2 + 3 + 6 = 12 and
% sigma(2,6) = 1^2 + 2^2 +3^2 + 6^2 = 50. sigma(0,n) is just the number of
% divisors of n.
% Note: This program requires first downloading factor2.
function s = sigma(k,n)
if n==0
s=0;
return;
end
if n==1
s=1;
return;
end
fax = factor2(n);
if k==0
s = prod(fax(:,2) + 1);
return;
else
s = 1;
len = length(fax(:,1));
for m=1:len
p = fax(m,1);
q = p^k;
e = fax(m,2);
s = s * (q^(e+1) - 1)/(q - 1);
end
end
|
|
Contact us at files@mathworks.com