# Counting

Counting is a language invented by User:A whose control flow only contains When blocks. The only mutable values is the instruction count and the accumulator. The instruction count increments after every executed when block (skipped blocks aren't counted) and starts at 0. It cannot be assigned. (The counter is incremented every time before the execution of the when block.)

The accumulator, initialized at 0, can only be added by the (potentially processed) instruction count. The accumulator cannot be subtracted or assigned by the instruction count, and so on.

Even if none of the conditions are fullfilled, the language continues to execute without stopping, as well as incrementing the counter by 1. You can use `halt` to stop the program.

## Example (Infinite counter)

```when cnt > 0
out cnt
```

## Range from 2 to 100.

```when cnt > 100
halt
when cnt > 2
out cnt
```

## Count up with a step of 2, starting with 2.

```when cnt % 3 == 2
acc += cnt
out acc
```

## Digital root calculator

```when cnt - 1 == 1 + (acc - 1) % 9
out cnt - 1
halt
```

## Line-based cat program

```when 1
out acc
```

## Hello, World!

```when 1
out "Hello, World!"
halt
```

## Truth-machine

```when cnt == 1
out acc
when acc == 0
halt
when acc == 1
out acc
```

## Fibonacci sequence

Swap() is in pseudo-code ...

```when cnt == acc - cnt
out acc
acc += cnt
acc += cnt
when cnt < acc - cnt
% Pass.
when cnt == acc - cnt
acc += 0 - cnt
```

```when cnt == 0

when cnt == acc
out acc + cnt
halt
```

## Triangular Numbers

Outputs in unary.

```when cnt == 0
when cnt < acc
out "*" * cnt

% 1 + 2 + ... + acc
```

## Factorial Sequence

```when cnt == 0