NUMCOMB combinatorial number. NUMCOMB(n,k) calculates the combinatorial number defined as n!/(k!.(n-k)!).
0001 function y=numcomb(n,k) 0002 0003 % NUMCOMB combinatorial number. 0004 % 0005 % NUMCOMB(n,k) calculates the combinatorial number defined 0006 % as n!/(k!.(n-k)!). 0007 0008 %-------------------------------------------------------- 0009 % Copyright (C) 1994, 1995, 1996, by Universidad de Vigo 0010 % 0011 % 0012 % Uvi_Wave is free software; you can redistribute it and/or modify it 0013 % under the terms of the GNU General Public License as published by the 0014 % Free Software Foundation; either version 2, or (at your option) any 0015 % later version. 0016 % 0017 % Uvi_Wave is distributed in the hope that it will be useful, but WITHOUT 0018 % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0019 % FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0020 % for more details. 0021 % 0022 % You should have received a copy of the GNU General Public License 0023 % along with Uvi_Wave; see the file COPYING. If not, write to the Free 0024 % Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 0025 % 0026 % Author: Nuria Gonzalez Prelcic 0027 % e-mail: Uvi_Wave@tsc.uvigo.es 0028 %-------------------------------------------------------- 0029 0030 0031 0032 if n==k, 0033 y=1; 0034 elseif k==0, 0035 y=1; 0036 elseif k==1, 0037 y=n; 0038 else 0039 y=fact(n)/(fact(k)*fact(n-k)); 0040 end