EDIT: I have removed the rest of the FACTORIAL function in this post as per Jan's suggestion. To explain myself, I did consider whether posting a MATLAB function to Answers is copyright infringement. I didn't think so because the code is in MATLAB's language...and I didn't think it would be that helpful for a nefarious party to see a function in MATLAB like this. I may be mistaken, though, and will refrain from posting any MATLAB code from now on. But my question still stands...
I am confused about a line in MATLAB's FACTORIAL function. If you type "open factorial" in the command window and check (somewhere around) line 20, it says:
n(:) is an array of real, nonnegative integers. 1 is appended to n(:) and that is passed to the MAX function...the only reason I can see for that 1 is to prevent MAX from returning 0 if n(:) consists entirely of 0's. But the rest of the code doesn't seem to require the MAX to return 1 instead of 0. What could be the purpose of this appended 1? I ask because I'm just learning MATLAB and may be mistaken in thinking this extra 1 is unnecessary.
2 Comments
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/41345-what-is-the-purpose-of-this-line-in-matlab-s-factorial-m-function#comment_84733
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/41345-what-is-the-purpose-of-this-line-in-matlab-s-factorial-m-function#comment_84733
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/41345-what-is-the-purpose-of-this-line-in-matlab-s-factorial-m-function#comment_84996
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/41345-what-is-the-purpose-of-this-line-in-matlab-s-factorial-m-function#comment_84996
Sign in to comment.