fibonacci-2.hvml 811 Bytes
Newer Older
Vincent Wei's avatar
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 array variable ($!) and negative index</p>
Vincent Wei's avatar
Vincent Wei committed
11
12
        </header>

Vincent Wei's avatar
Vincent Wei committed
13
        <init as='fibonacci' temp>
Vincent Wei's avatar
Vincent Wei committed
14
15
16
            [0, 1, ]
        </init>

17
        <iterate on 1 by="ADD: LT 2000 BY $!.fibonacci[-2]">
xuxiaohong's avatar
xuxiaohong committed
18
            <update on="$2!.fibonacci" to="append" with="$?" />
Vincent Wei's avatar
Vincent Wei committed
19
20
        </iterate>

Vincent Wei's avatar
Vincent Wei committed
21
22
        <section>
            <ol>
xuxiaohong's avatar
xuxiaohong committed
23
                <iterate on="$3!.fibonacci">
Vincent Wei's avatar
Vincent Wei committed
24
25
26
27
                    <li>$?</li>
                </iterate>
            </ol>
        </section>
Vincent Wei's avatar
Vincent Wei committed
28
29

        <footer>
xuxiaohong's avatar
xuxiaohong committed
30
            <p>Totally $EJSON.count($2!.fibonacci) numbers.</p>
Vincent Wei's avatar
Vincent Wei committed
31
32
33
34
        </footer>
    </body>

</hvml>