function nfact = factorial(n)

if (n==1) nfact=1; return; end

nfact = n*factorial(n-1);



    

