user
Task

Start an integer value at   **1024**.

Loop while it is greater than zero.

Print the value (with a newline) and divide it by two each time through the loop.

Related tasks

* Loop over multiple arrays simultaneously
* Loops/Break
* Loops/Continue
* Loops/Do-while
* Loops/Downward for
* Loops/For
* Loops/For with a specified step
* Loops/Foreach
* Loops/Increment loop index within loop body
* Loops/Infinite
* Loops/N plus one half
* Loops/Nested
* Loops/While
* Loops/with multiple ranges
* Loops/Wrong ranges
assistant
(formerly Perl 6)

Here is a straightforward translation of the task description:

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

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

```
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:

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