function f = factorialInt16(n)
% factorialInt16(n) returns the factorial of n with all calculations of type int16.
   f=int16(1);
   while(n>1)
       f=f*int16(n);
       n=int16(n-1);
   end