View Problem

Perform an action multiple times based on a boolean condition, checked before the first action (WHILE .. DO)

Starting with a variable x=1, Print the sequence "1,2,4,8,16,32,64,128," by doubling x and checking that x is less than 150.
DiskEdit
ruby
x=1
while x < 150
puts x
x *=2
end
ExpandDiskEdit
java
int x = 1;
while (x < 150) {
System.out.println(x+",");
x*=2;
}
DiskEdit
perl
my $x = 1;
while($x < 150) {
print $x, ",";
$x *=2
}
DiskEdit
groovy
x = 1
while (x < 150) {
print x + ","
x *= 2
}
println()
ExpandDiskEdit
scala
var x = 1 ; while (x < 150) { printf("%d,", x) ; x *= 2 }
DiskEdit
python
x = 1
while x < 150:
print '%s, ' % x,
x *= 2
ExpandDiskEdit
cpp C++/CLI .NET 2.0
int x = 1;

while (x < 150) { x *= 2; Console::Write("{0},", x); }
Console::WriteLine();
ExpandDiskEdit
cpp
for (int x = 1; x < 150; x *= 2) { std::cout << x << ","; }
std::cout << std::endl;
ExpandDiskEdit
fsharp
let mutable x = 1
while x < 150 do printf "%d, " x ; (x <- x * 2) done
ExpandDiskEdit
erlang
X = 1, print_while_X_less_150(X).
ExpandDiskEdit
erlang
Pred = fun (X) -> X < 150 end,
Action = fun (X) -> io:format("~B,", [X]), X * 2 end,
X = 1,

while_do(Pred, Action, X).
ExpandDiskEdit
php
$x = 1;
while($x < 150) {
echo "$x,";
$x *= 2;
}
ExpandDiskEdit
php
$x = 0;
$c = pow(2, $x);
while($c < 150) {
echo "$c,";
$c = pow(2, $x++);
}

Submit a new solution for ruby, java, perl, groovy ...