<?xml version="1.0"?>
<flowgorithm fileversion="2.11">
    <attributes>
        <attribute name="name" value=""/>
        <attribute name="authors" value="fox"/>
        <attribute name="about" value=""/>
        <attribute name="saved" value="2020-04-06 01:38:53 dop."/>
        <attribute name="created" value="Zm94O0RFU0tUT1AtQTRBVE1MRjsyMDIwLTA0LTA1OzExOjI0OjA4IGRvcC47Mjg5MA=="/>
        <attribute name="edited" value="Zm94O0RFU0tUT1AtQTRBVE1MRjsyMDIwLTA0LTA2OzAxOjM4OjUzIGRvcC47ODszMDEw"/>
    </attributes>
    <function name="Main" type="None" variable="">
        <parameters/>
        <body>
            <comment text="Deklarace: 'n' ... &#269;&#237;slo, pro kter&#233; bude vypo&#269;ten faktori&#225;l"/>
            <declare name="n" type="Integer" array="False" size=""/>
            <output expression="&quot;V&#253;po&#269;et faktori&#225;lu&quot;" newline="True"/>
            <comment text="V&#253;zva k zad&#225;n&#237; &#269;&#237;sla"/>
            <output expression="&quot;Zadejte &#269;&#237;slo: &quot;" newline="False"/>
            <comment text="Na&#269;ten&#237; &#269;&#237;sla"/>
            <input variable="n"/>
            <comment text="V&#253;pis textu a hodnoty faktori&#225;lu, kter&#253; je v&#253;stupem zavolan&#233; funkce s p&#345;edan&#253;m parametrem 'n'"/>
            <output expression="&quot;Faktori&#225;l (cyklus while): &quot; &amp; ToString(FaktorialWhile(n))" newline="True"/>
            <output expression="&quot;Faktori&#225;l (cyklus do-while): &quot; &amp; ToString(FaktorialDoWhile(n))" newline="True"/>
            <output expression="&quot;Faktori&#225;l (cyklus for): &quot; &amp; ToString(FaktorialFor(n))" newline="True"/>
            <output expression="&quot;Faktori&#225;l (rekurze): &quot; &amp; ToString(FaktorialVolaniRekurze(n))" newline="True"/>
        </body>
    </function>
    <function name="FaktorialDoWhile" type="Integer" variable="f">
        <parameters>
            <parameter name="n" type="Integer" array="False"/>
        </parameters>
        <body>
            <comment text="Deklarace: 'i' ... &#269;&#237;ta&#269; (aktu&#225;ln&#237; &#269;&#237;slo v sou&#269;inu); 'f' ... hodnota faktori&#225;lu"/>
            <declare name="i, f" type="Integer" array="False" size=""/>
            <comment text="Inicializace"/>
            <assign variable="i" expression="1"/>
            <assign variable="f" expression="1"/>
            <do expression="i &lt;= n">
                <comment text="V&#253;po&#269;et faktori&#225;lu"/>
                <assign variable="f" expression="f * i"/>
                <comment text="Inkrementace &#269;&#237;ta&#269;e"/>
                <assign variable="i" expression="i + 1"/>
                <comment text="Opakuj, dokud je &#269;&#237;ta&#269; men&#353;&#237;, nebo roven &#269;&#237;slu pro v&#253;po&#269;et faktori&#225;lu"/>
            </do>
            <comment text="N&#225;vrat vypo&#269;ten&#233; hodnoty faktori&#225;lu"/>
        </body>
    </function>
    <function name="FaktorialFor" type="Integer" variable="f">
        <parameters>
            <parameter name="n" type="Integer" array="False"/>
        </parameters>
        <body>
            <comment text="Deklarace: 'i' ... &#269;&#237;ta&#269; (aktu&#225;ln&#237; &#269;&#237;slo v sou&#269;inu); 'f' ... hodnota faktori&#225;lu"/>
            <declare name="i, f" type="Integer" array="False" size=""/>
            <comment text="Inicializace"/>
            <assign variable="f" expression="1"/>
            <for variable="i" start="1" end="n" direction="inc" step="1">
                <comment text="V&#253;po&#269;et faktori&#225;lu"/>
                <assign variable="f" expression="f * i"/>
            </for>
            <comment text="N&#225;vrat vypo&#269;ten&#233; hodnoty faktori&#225;lu"/>
        </body>
    </function>
    <function name="FaktorialRekurze" type="Integer" variable="f">
        <parameters>
            <parameter name="n" type="Integer" array="False"/>
        </parameters>
        <body>
            <declare name="f" type="Integer" array="False" size=""/>
            <comment text="Pokud bylo zad&#225;no nulov&#233; &#269;&#237;slo"/>
            <if expression="n == 0">
                <then>
                    <comment text="Faktori&#225;l je 1"/>
                    <assign variable="f" expression="1"/>
                </then>
                <else>
                    <comment text="Rekurzivn&#237; vol&#225;n&#237; funkce (funkce vol&#225; sama sebe)"/>
                    <assign variable="f" expression="n * FaktorialRekurze(n - 1)"/>
                </else>
            </if>
        </body>
    </function>
    <function name="FaktorialVolaniRekurze" type="Integer" variable="f">
        <parameters>
            <parameter name="n" type="Integer" array="False"/>
        </parameters>
        <body>
            <comment text="Deklarace: 'f' ... hodnota faktori&#225;lu"/>
            <declare name="f" type="Integer" array="False" size=""/>
            <comment text="Vol&#225;n&#237; funkce pro v&#253;po&#269;et faktori&#225;lu pomoc&#237; rekurze"/>
            <assign variable="f" expression="FaktorialRekurze(n)"/>
            <comment text="N&#225;vrat vypo&#269;ten&#233; hodnoty faktori&#225;lu"/>
        </body>
    </function>
    <function name="FaktorialWhile" type="Integer" variable="f">
        <parameters>
            <parameter name="n" type="Integer" array="False"/>
        </parameters>
        <body>
            <comment text="Deklarace: 'i' ... &#269;&#237;ta&#269; (aktu&#225;ln&#237; &#269;&#237;slo v sou&#269;inu); 'f' ... hodnota faktori&#225;lu"/>
            <declare name="i, f" type="Integer" array="False" size=""/>
            <comment text="Inicializace"/>
            <assign variable="i" expression="1"/>
            <assign variable="f" expression="1"/>
            <comment text="Opakuj, pokud je &#269;&#237;ta&#269; men&#353;&#237;, nebo roven &#269;&#237;slu pro v&#253;po&#269;et faktori&#225;lu"/>
            <while expression="i &lt;= n">
                <comment text="V&#253;po&#269;et faktori&#225;lu"/>
                <assign variable="f" expression="f * i"/>
                <comment text="Inkrementace &#269;&#237;ta&#269;e"/>
                <assign variable="i" expression="i + 1"/>
            </while>
            <comment text="N&#225;vrat vypo&#269;ten&#233; hodnoty faktori&#225;lu"/>
        </body>
    </function>
</flowgorithm>
