File: fizzbuzz.tiny

package info (click to toggle)
pyparsing 3.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 12,200 kB
  • sloc: python: 30,867; ansic: 422; sh: 112; makefile: 24
file content (29 lines) | stat: -rw-r--r-- 590 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* FizzBuzz in Tiny
   Count from 1 to (limit), printing "Fizz" for multiples of 3, "Buzz" for multiples of 5,
   and "FizzBuzz" for multiples of 15.
*/

int is_divisible(int a, int b) {
    float quo := a / b;
    int iquo := quo;
    return quo = iquo;
}

int main() {
    limit := 100;

    i := 0;
    repeat
        i := i + 1;
        show_num := 1;

        if is_divisible(i, 3) then write "Fizz"; show_num := 0; end
        if is_divisible(i, 5) then write "Buzz"; show_num := 0; end
        if show_num then write i; end

        write endl;

    until i = limit

    return 0;
}