> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/perl6-rosettacode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/perl6-rosettacode/programming_tasks/l/loops/while.md).

# While

Here is a straightforward translation of the task description:

```perl
my $n = 1024; while $n > 0 { say $n; $n div= 2 }
```

The same thing with a C-style loop and a bitwise shift operator:

```perl
loop (my $n = 1024; $n > 0; $n +>= 1) { say $n }
```

And here's how you'd *really* write it, using a sequence operator that intuits the division for you:

```perl
.say for 1024, 512, 256 ... 1
```
