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.
python x = 1
while x < 150:
print '%s, ' % x,
x *= 2
x = 1
while x < 150:
print '%s, ' % x,
x *= 2
csharp int x = 1;
while (x < 150)
{
x *= 2;
Console.Write("{0},", x);
}
int x = 1;
while (x < 150)
{
x *= 2;
Console.Write("{0},", x);
}
java int x = 1;
while (x < 150) {
System.out.println(x+",");
x*=2;
}
public class SolutionXX {
public static void main(String[] args) {
int x = 1;
while (x < 150) {
System.out.println(x+",");
x*=2;
}
}
}
fantom x := 1
while (x < 150) {
Env.cur.out.print("$x,")
x *= 2
}
echo
class SolutionXX
{
Void main()
{
x := 1
while (x < 150) {
Env.cur.out.print("$x,")
x *= 2
}
echo
}
}
Submit a new solution for
python,
csharp,
java, or
fantom
There are 16 other solutions in
additional languages (
clojure,
cpp,
erlang,
fsharp ...)