CogniPilot

MODELICA LIBRARY · ENGINEERING REFERENCE

function

Polynomials.fallingFactorial

n*(n-1)*...*(n-order+1)

Public declarations

Explicit source declarations; dimensions, modifications and defaults are shown as written, without evaluation.

RoleNameTypeDimensions / attributes / defaultDescription
inputnInteger(min=0)
inputorderInteger(min=0)
outputvalueReal

Modelica declarations and implementation

Show parameters, interfaces and source

Parameters, inputs, outputs, defaults and equations from the source file.

function fallingFactorial "n*(n-1)*...*(n-order+1)"
  input Integer n(min=0);
  input Integer order(min=0);
  output Real value;
algorithm
  value := 1.0;
  if order > n then
    value := 0.0;
  else
    for factorIndex in 0:order - 1 loop
      value := value * (n - factorIndex);
    end for;
  end if;
end fallingFactorial;