fibonacci-4.hvml 998 Bytes
Newer Older
Vincent Wei's avatar
tune    
Vincent Wei committed
1
2
3
4
5
6
7
8
9
<!DOCTYPE hvml>
<hvml target="html" lang="en">
    <head>
        <title>Fibonacci Numbers</title>
    </head>

    <body>
        <header>
            <h1>Fibonacci Numbers less than 2000</h1>
Vincent Wei's avatar
Vincent Wei committed
10
            <p hvml:raw>Using temporary variables in two levels</p>
Vincent Wei's avatar
tune    
Vincent Wei committed
11
12
        </header>

Vincent Wei's avatar
Vincent Wei committed
13
        <init as="count" with=2 temp />
Vincent Wei's avatar
tune    
Vincent Wei committed
14
15

        <section>
Vincent Wei's avatar
Vincent Wei committed
16
            <dl id="myAnchor">
Vincent Wei's avatar
Vincent Wei committed
17
18
                <init as="last_one" with=0 temp />
                <init as="last_two" with=1 temp />
Vincent Wei's avatar
tune    
Vincent Wei committed
19
20

                <iterate on 1 by="ADD: LT 2000 BY $!.last_one">
Vincent Wei's avatar
Vincent Wei committed
21
22
                    <init as="last_one" at="#myAnchor" with="last_two" temp />
                    <init as="last_two" at="#myAnchor" with="$?" temp />
23

xuxiaohong's avatar
xuxiaohong committed
24
                    <update on="$4!" at=".count" to="displace" with += 1 />
Vincent Wei's avatar
tune    
Vincent Wei committed
25
26
27
28
29
30
31
                    <dt>$%</dt>
                    <dd>$?</dd>
                </iterate>
            </dl>
        </section>

        <footer>
xuxiaohong's avatar
xuxiaohong committed
32
            <p>Totally $2!.count numbers.</p>
Vincent Wei's avatar
tune    
Vincent Wei committed
33
34
35
36
        </footer>
    </body>

</hvml>