Factorial in Octave

Published on 09 December 2023 (Updated: 09 December 2023)

Welcome to the Factorial in Octave page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

function factorial()
    usage = 'Usage: please input a non-negative integer';
    arg_list = argv();
    nargin = length(arg_list);
    if nargin == 0
        disp(usage);
        return;
    end

    n = str2num(arg_list{1});
    if length(n) ~= 1 || mod(n, 1) ~= 0 || n < 0
        disp(usage);
        return;
    end

    x = 1;
    for i = 1:n
        x = x * i;
    end

    disp(x);
end

Factorial in Octave was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

No 'How to Implement the Solution' section available. Please consider contributing.

How to Run the Solution

No 'How to Run the Solution' section available. Please consider contributing.