<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1rdu30p" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.2.0">
  <bpmn:process id="Camunda_Factorial_1t2uk52" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1">
      <bpmn:outgoing>Flow_0ctisw0</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:endEvent id="Event_006m5e2">
      <bpmn:incoming>Flow_1pzef2i</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_0ctisw0" sourceRef="StartEvent_1" targetRef="Gateway_1gt9bik" />
    <bpmn:exclusiveGateway id="Gateway_1l66dsx" name="Check End 1" default="Flow_0jh9it5">
      <bpmn:incoming>Flow_1lvrhhd</bpmn:incoming>
      <bpmn:outgoing>Flow_0jh9it5</bpmn:outgoing>
      <bpmn:outgoing>Flow_0cko92q</bpmn:outgoing>
    </bpmn:exclusiveGateway>
    <bpmn:sequenceFlow id="Flow_0s7mkvu" sourceRef="Task_Factorial_End_09drn0k" targetRef="Gateway_0me35pi" />
    <bpmn:userTask id="Task_Factorial_End_09drn0k" name="Factorial ${title}" camunda:assignee="demo">
      <bpmn:extensionElements>
        <camunda:formData>
          <camunda:formField id="FormField_3mhfnrm" label="${title}!" type="string" defaultValue="${ x_0f6ddpq }" />
        </camunda:formData>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_10v9m0r</bpmn:incoming>
      <bpmn:outgoing>Flow_0s7mkvu</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:sequenceFlow id="Flow_1b889hc" sourceRef="Activity_0sgz5ev" targetRef="Gateway_1mlgugf" />
    <bpmn:task id="Activity_0sgz5ev" name="Recursion Input">
      <bpmn:extensionElements>
        <camunda:inputOutput>
          <camunda:outputParameter name="n_in_3nt500l">
            <camunda:script scriptFormat="JavaScript">n_in_3nt500l = execution.getVariable('n_in_3nt500l');</camunda:script>
          </camunda:outputParameter>
          <camunda:outputParameter name="count_in_0b9sppj">
            <camunda:script scriptFormat="JavaScript">count_in_0b9sppj = execution.getVariable('count_in_0b9sppj');</camunda:script>
          </camunda:outputParameter>
          <camunda:outputParameter name="x_in_0f6ddpq">
            <camunda:script scriptFormat="JavaScript">x_in_0f6ddpq = execution.getVariable('x_in_0f6ddpq');</camunda:script>
          </camunda:outputParameter>
        </camunda:inputOutput>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_0n4pmiy</bpmn:incoming>
      <bpmn:outgoing>Flow_1b889hc</bpmn:outgoing>
    </bpmn:task>
    <bpmn:exclusiveGateway id="Gateway_1gt9bik" name="Check Init" default="Flow_11sxtx8">
      <bpmn:incoming>Flow_0ctisw0</bpmn:incoming>
      <bpmn:outgoing>Flow_0n4pmiy</bpmn:outgoing>
      <bpmn:outgoing>Flow_11sxtx8</bpmn:outgoing>
    </bpmn:exclusiveGateway>
    <bpmn:sequenceFlow id="Flow_0n4pmiy" sourceRef="Gateway_1gt9bik" targetRef="Activity_0sgz5ev">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.hasVariable("n_in_3nt500l") == true}</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="Flow_11sxtx8" sourceRef="Gateway_1gt9bik" targetRef="Activity_1mejrha" />
    <bpmn:callActivity id="Activity_00nq3s8" name="Call Self" calledElement="Camunda_Factorial_1t2uk52">
      <bpmn:extensionElements>
        <camunda:in variables="all" />
        <camunda:out variables="all" />
        <camunda:inputOutput>
          <camunda:inputParameter name="n_in_3nt500l">${n_in_3nt500l}</camunda:inputParameter>
          <camunda:inputParameter name="count_in_0b9sppj">${count_in_0b9sppj - 1}</camunda:inputParameter>
          <camunda:inputParameter name="x_in_0f6ddpq">${x_in_0f6ddpq}</camunda:inputParameter>
          <camunda:outputParameter name="n_3nt500l">${n_out_3nt500l}</camunda:outputParameter>
          <camunda:outputParameter name="count_0b9sppj">${count_out_0b9sppj}</camunda:outputParameter>
          <camunda:outputParameter name="x_0f6ddpq">${x_out_0f6ddpq}</camunda:outputParameter>
        </camunda:inputOutput>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_0jh9it5</bpmn:incoming>
      <bpmn:outgoing>Flow_1q1ganv</bpmn:outgoing>
    </bpmn:callActivity>
    <bpmn:inclusiveGateway id="Gateway_1mlgugf">
      <bpmn:incoming>Flow_1fxdsgl</bpmn:incoming>
      <bpmn:incoming>Flow_1b889hc</bpmn:incoming>
      <bpmn:outgoing>Flow_1lvrhhd</bpmn:outgoing>
    </bpmn:inclusiveGateway>
    <bpmn:sequenceFlow id="Flow_1lvrhhd" sourceRef="Gateway_1mlgugf" targetRef="Gateway_1l66dsx" />
    <bpmn:sequenceFlow id="Flow_1fxdsgl" sourceRef="Activity_0iyl80l" targetRef="Gateway_1mlgugf" />
    <bpmn:task id="Activity_09lpo08" name="Recursion Output">
      <bpmn:extensionElements>
        <camunda:inputOutput>
          <camunda:outputParameter name="count_out_0b9sppj">${count_0b9sppj}</camunda:outputParameter>
          <camunda:outputParameter name="x_out_0f6ddpq">${x_0f6ddpq * n_3nt500l }</camunda:outputParameter>
          <camunda:outputParameter name="n_out_3nt500l">${n_3nt500l - 1 }</camunda:outputParameter>
        </camunda:inputOutput>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_0thalpg</bpmn:incoming>
      <bpmn:outgoing>Flow_1pzef2i</bpmn:outgoing>
    </bpmn:task>
    <bpmn:exclusiveGateway id="Gateway_1j1whrb" name="Check End 2" default="Flow_17s6rs5">
      <bpmn:incoming>Flow_1q1ganv</bpmn:incoming>
      <bpmn:outgoing>Flow_17s6rs5</bpmn:outgoing>
      <bpmn:outgoing>Flow_10v9m0r</bpmn:outgoing>
    </bpmn:exclusiveGateway>
    <bpmn:sequenceFlow id="Flow_0jh9it5" sourceRef="Gateway_1l66dsx" targetRef="Activity_00nq3s8" />
    <bpmn:sequenceFlow id="Flow_0cko92q" sourceRef="Gateway_1l66dsx" targetRef="Activity_12yds7t">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${count_in_0b9sppj == 0}</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="Flow_1q1ganv" sourceRef="Activity_00nq3s8" targetRef="Gateway_1j1whrb" />
    <bpmn:sequenceFlow id="Flow_17s6rs5" sourceRef="Gateway_1j1whrb" targetRef="Gateway_0me35pi" />
    <bpmn:sequenceFlow id="Flow_10v9m0r" sourceRef="Gateway_1j1whrb" targetRef="Task_Factorial_End_09drn0k">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${n_3nt500l == 0}</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="Flow_1pzef2i" sourceRef="Activity_09lpo08" targetRef="Event_006m5e2" />
    <bpmn:endEvent id="Event_1f0xx8o">
      <bpmn:incoming>Flow_07bub76</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:task id="Activity_12yds7t" name="Recursion End">
      <bpmn:extensionElements>
        <camunda:inputOutput>
          <camunda:outputParameter name="n_out_3nt500l">
            <camunda:script scriptFormat="JavaScript">//execution.setVariable('n_out_3nt500l', n_in_3nt500l - 1 );
n_out_3nt500l = execution.getVariable('n_in_3nt500l') - 1;</camunda:script>
          </camunda:outputParameter>
          <camunda:outputParameter name="count_out_0b9sppj">
            <camunda:script scriptFormat="JavaScript">//execution.setVariable('count_out_0b9sppj', count_in_0b9sppj);
count_out_0b9sppj = execution.getVariable('count_in_0b9sppj');</camunda:script>
          </camunda:outputParameter>
          <camunda:outputParameter name="x_out_0f6ddpq">
            <camunda:script scriptFormat="JavaScript">//execution.setVariable('x_out_0f6ddpq', x_in_0f6ddpq);
x_out_0f6ddpq = execution.getVariable('x_in_0f6ddpq');</camunda:script>
          </camunda:outputParameter>
        </camunda:inputOutput>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_0cko92q</bpmn:incoming>
      <bpmn:outgoing>Flow_07bub76</bpmn:outgoing>
    </bpmn:task>
    <bpmn:sequenceFlow id="Flow_07bub76" sourceRef="Activity_12yds7t" targetRef="Event_1f0xx8o" />
    <bpmn:sequenceFlow id="Flow_0thalpg" sourceRef="Gateway_0me35pi" targetRef="Activity_09lpo08" />
    <bpmn:inclusiveGateway id="Gateway_0me35pi">
      <bpmn:incoming>Flow_17s6rs5</bpmn:incoming>
      <bpmn:incoming>Flow_0s7mkvu</bpmn:incoming>
      <bpmn:outgoing>Flow_0thalpg</bpmn:outgoing>
    </bpmn:inclusiveGateway>
    <bpmn:scriptTask id="Activity_0iyl80l" name="Init" scriptFormat="Javascript">
      <bpmn:extensionElements>
        <camunda:inputOutput>
          <camunda:outputParameter name="Output_1e5ahsf">
            <camunda:script scriptFormat="JavaScript">var x_temp = 1;
execution.setVariable("x_temp", x_temp);</camunda:script>
          </camunda:outputParameter>
        </camunda:inputOutput>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_1sbv5hi</bpmn:incoming>
      <bpmn:outgoing>Flow_1fxdsgl</bpmn:outgoing>
      <bpmn:script>var x = execution.getVariable('FormField_037isrf');
execution.setVariable('n_in_3nt500l', x);
execution.setVariable('count_in_0b9sppj', x);
execution.setVariable('x_in_0f6ddpq', x);
execution.setVariable('title', x);</bpmn:script>
    </bpmn:scriptTask>
    <bpmn:userTask id="Activity_1mejrha" name="Input X" camunda:assignee="demo">
      <bpmn:extensionElements>
        <camunda:formData>
          <camunda:formField id="FormField_037isrf" label="X?" type="long" defaultValue="5" />
        </camunda:formData>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_11sxtx8</bpmn:incoming>
      <bpmn:outgoing>Flow_1sbv5hi</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:sequenceFlow id="Flow_1sbv5hi" sourceRef="Activity_1mejrha" targetRef="Activity_0iyl80l" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Camunda_Factorial_1t2uk52">
      <bpmndi:BPMNEdge id="Flow_0thalpg_di" bpmnElement="Flow_0thalpg">
        <di:waypoint x="1059" y="117" />
        <di:waypoint x="1105" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_07bub76_di" bpmnElement="Flow_07bub76">
        <di:waypoint x="580" y="310" />
        <di:waypoint x="580" y="382" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1pzef2i_di" bpmnElement="Flow_1pzef2i">
        <di:waypoint x="1205" y="117" />
        <di:waypoint x="1255" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_10v9m0r_di" bpmnElement="Flow_10v9m0r">
        <di:waypoint x="840" y="142" />
        <di:waypoint x="840" y="270" />
        <di:waypoint x="891" y="270" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_17s6rs5_di" bpmnElement="Flow_17s6rs5">
        <di:waypoint x="865" y="117" />
        <di:waypoint x="1009" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1q1ganv_di" bpmnElement="Flow_1q1ganv">
        <di:waypoint x="760" y="117" />
        <di:waypoint x="815" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0cko92q_di" bpmnElement="Flow_0cko92q">
        <di:waypoint x="580" y="142" />
        <di:waypoint x="580" y="230" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0jh9it5_di" bpmnElement="Flow_0jh9it5">
        <di:waypoint x="605" y="117" />
        <di:waypoint x="660" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1fxdsgl_di" bpmnElement="Flow_1fxdsgl">
        <di:waypoint x="410" y="270" />
        <di:waypoint x="470" y="270" />
        <di:waypoint x="470" y="142" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1lvrhhd_di" bpmnElement="Flow_1lvrhhd">
        <di:waypoint x="495" y="117" />
        <di:waypoint x="555" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_11sxtx8_di" bpmnElement="Flow_11sxtx8">
        <di:waypoint x="240" y="142" />
        <di:waypoint x="240" y="420" />
        <di:waypoint x="310" y="420" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0n4pmiy_di" bpmnElement="Flow_0n4pmiy">
        <di:waypoint x="265" y="117" />
        <di:waypoint x="310" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1b889hc_di" bpmnElement="Flow_1b889hc">
        <di:waypoint x="410" y="117" />
        <di:waypoint x="445" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0s7mkvu_di" bpmnElement="Flow_0s7mkvu">
        <di:waypoint x="991" y="270" />
        <di:waypoint x="1034" y="270" />
        <di:waypoint x="1034" y="142" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0ctisw0_di" bpmnElement="Flow_0ctisw0">
        <di:waypoint x="178" y="117" />
        <di:waypoint x="215" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1sbv5hi_di" bpmnElement="Flow_1sbv5hi">
        <di:waypoint x="360" y="380" />
        <di:waypoint x="360" y="310" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="142" y="99" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_006m5e2_di" bpmnElement="Event_006m5e2">
        <dc:Bounds x="1255" y="99" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Gateway_1l66dsx_di" bpmnElement="Gateway_1l66dsx" isMarkerVisible="true">
        <dc:Bounds x="555" y="92" width="50" height="50" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="549" y="73" width="63" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_070bt3s_di" bpmnElement="Task_Factorial_End_09drn0k">
        <dc:Bounds x="891" y="230" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1ohoxi3_di" bpmnElement="Activity_0sgz5ev">
        <dc:Bounds x="310" y="77" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Gateway_1gt9bik_di" bpmnElement="Gateway_1gt9bik" isMarkerVisible="true">
        <dc:Bounds x="215" y="92" width="50" height="50" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="215" y="73" width="50" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_0nnj098_di" bpmnElement="Activity_00nq3s8">
        <dc:Bounds x="660" y="77" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Gateway_0zpdl6y_di" bpmnElement="Gateway_1mlgugf">
        <dc:Bounds x="445" y="92" width="50" height="50" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_09lpo08_di" bpmnElement="Activity_09lpo08">
        <dc:Bounds x="1105" y="77" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Gateway_1j1whrb_di" bpmnElement="Gateway_1j1whrb" isMarkerVisible="true">
        <dc:Bounds x="815" y="92" width="50" height="50" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="809" y="73" width="63" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_1f0xx8o_di" bpmnElement="Event_1f0xx8o">
        <dc:Bounds x="562" y="382" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_12yds7t_di" bpmnElement="Activity_12yds7t">
        <dc:Bounds x="530" y="230" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Gateway_0qrgt5h_di" bpmnElement="Gateway_0me35pi">
        <dc:Bounds x="1009" y="92" width="50" height="50" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1l5kqxp_di" bpmnElement="Activity_0iyl80l">
        <dc:Bounds x="310" y="230" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1ntnk45_di" bpmnElement="Activity_1mejrha">
        <dc:Bounds x="310" y="380" width="100" height="80" />
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>
