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.
|
| factor2( n )
|
% factor2 by David Terr, Raytheon Inc., 5-19-04
% Given an integer n, return the prime factorization of n as a
% 2*k matrix, with the k distinct prime factors in the left column and
% exponents in the right column. Here, -1 is counted as a prime.
% For example, factor2(12) returns the matrix 2 2 and factor2(-12) returns -1 1
% 3 1 2 2
% 3 1
function fac = factor2( n )
if n == 0 || n == 1
fac = [n 0];
return;
end
if n < 0
fac = [-1 1;factor2(-n)];
return;
end
fac0 = factor(n);
len = length(fac0);
fac1 = zeros(len,2);
p = fac0(1);
q = p;
fac1(1,1) = p;
fac1(1,2) = 1;
m = 1;
k = 2;
while k <= len
q = fac0(k);
while (q == p && k < len)
fac1(m,2) = fac1(m,2) + 1;
k = k + 1;
q = fac0(k);
end
if q == p
k = k + 1;
fac1(m,2) = fac1(m,2) + 1;
else
p = q;
m = m + 1;
fac1(m,1) = q;
fac1(m,2) = 1;
k = k + 1;
end
end
fac = fac1(1:m,:);
|
|
Contact us at files@mathworks.com