Sed Seyedi

↳ On programming, startups and more.
blog projects about contact

SunSed Program to Find the Fibonacci Series Using Recursion

To be honest, I was surprised that it was possible, the following tag (function) takes the number of terms and determines the fibonacci series using recursion upto that term.

SunSed language is not very fast at calculating, looping and recursion, something I should work on in the future.

<s:tag name="fib">
    <s:case name="@case less">
        <s:if true="{{@content}} {{ < }} 2" return />
    </s:case>
    <s:if true="{{@case less}}">
        {{@content}}
    </s:if>
    <s:if false="{{@case less}}">
        <s:calc>
            <fib>
                <s:calc>
                    {{@content}} {{ - }} 1
                </s:calc>
            </fib>
            {{ + }}
            <fib>
                <s:calc>
                    {{@content}} {{ - }} 2
                </s:calc>
            </fib>
        </s:calc>
    </s:if>
</s:tag>

Now lets use our <fib> tag:

<fib>10</fib>

Result:

55    

For now, the maximum fib that you can calcualate using SunSed is fib of 18. That's because recursion is very slow in SunSed language and SunSed platform has a 1 second response limit -- forces all apps to respond in less than 1 second, otherwise you could calculate higher numbers of fibs.