function f=myfactorial(N)
% calculated factorial of the input. N!=N*(N-1)!
% input must be integer larger or equal to zero

% ALWAYS sanitize the input !!!
	if ( N<0 ) 
		error('wrong input, input must be >= 0');
	end
	if ( N~=floor(N) )
		error('input is not integer number');
	end
% -----------------	
	if ( N==0 )
		f=1; return;
	end
	f=N*myfactorial(N-1);
end
