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.
|
| Fibonacci(n)
|
% Fibonacci.m by David Terr, Raytheon, 5-11-04
% Given an integers n, compute the nth Fibonacci number.
function fib = Fibonacci(n)
% Make sure input is an integer.
if ( n ~= floor(n) )
error('Argument must be an integer.');
return;
end
if ~isreal(n)
error('Argument must be an integer.');
return;
end
if size(n,1) ~= 1 || size(n,2) ~= 1
error('Argument must be an integer.');
return;
end
if ( n == 0 )
fib = 0;
return;
end
if ( n < 0 )
fib = (-1)^(n+1) * Fibonacci(-n);
return;
end
alpha = (1 + sqrt(5))/2;
fib = round( alpha^n / sqrt(5) );
|
|
Contact us at files@mathworks.com