File: fib.azm

package info (click to toggle)
zoem 21-341-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, trixie
  • size: 1,980 kB
  • sloc: ansic: 9,386; sh: 1,113; makefile: 105
file content (22 lines) | stat: -rw-r--r-- 434 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
\:  test with 'zoem -i fib -o -'

\def{fib#1}{
   \push{fibonacci}
   \set{a}{1}
   \set{b}{1}
   \set{c}{0}
   \while{\let{\a <= \1}}{
      \setx{c}{\a}
      \setx{a}{\let{\a + \b}}
      \write{-}{txt}{\c\|}
      \setx{b}{\c}
   }
   \pop{fibonacci}
}

\: need to escape newlines below, lest they ruin the prompt

\write{-}{device}{Enter a number please, then press <cr>, <ctrl-d>\@{\N>\s}}\
\setx{num}{\zinsert{-}}\
\fib{\num}