Login
|
Signup
langref.org
-
python
,
csharp
,
fantom
,
fsharp
...
add..
all
cpp
erlang
go
groovy
haskell
java
ocaml
perl
php
ruby
scala
Home
All
Solved
Unsolved
Strings
Numbers
Regex
Lists
Maps
Structure
Files
Dates
OOP
Networking
XML
Algorithms
Misc
Parallel
View Problem
Structure
Loops
Perform an action a fixed number of times with a counter
Display the string
"10 .. 9 .. 8 .. 7 .. 6 .. 5 .. 4 .. 3 .. 2 .. 1 .. Liftoff!"
python
2.4
print " .. ".join(str(i) for i in range(10, 0, -1)), ".. liftoff!"
print " .. ".join(str(i) for i in range(10, 0, -1)), ".. liftoff!"
csharp
for (int i = 10; i > 0; i--)
{
Console.Write("{0} .. ", i);
}
Console.WriteLine("Liftoff!");
for (int i = 10; i > 0; i--)
{
Console.Write("{0} .. ", i);
}
Console.WriteLine("Liftoff!");
fantom
(10..1).each { Env.cur.out.print("$it .. ") }
Env.cur.out.print("Liftoff!")
class SolutionXX
{
Void main()
{
(10..1).each { Env.cur.out.print("$it .. ") }
Env.cur.out.print("Liftoff!")
}
}
fantom
for (i := 10; i >= 1; i--)
Env.cur.out.print("$i .. ")
Env.cur.out.print("Liftoff!")
class SolutionXX
{
Void main()
{
for (i := 10; i >= 1; i--)
Env.cur.out.print("$i .. ")
Env.cur.out.print("Liftoff!")
}
}
fsharp
for i = 10 downto 1 do printf "%d .. " i done
printfn "Liftoff!"
#light
open System
for i = 10 downto 1 do printf "%d .. " i done
printfn "Liftoff!"
fsharp
// Repetition via ranging over a Sequence type
for i in {10 .. -1 .. 1} do printf "%d .. " i done ; printfn "Liftoff!"
#light
open System
// Repetition via ranging over a Sequence type
for i in {10 .. -1 .. 1} do printf "%d .. " i done ; printfn "Liftoff!"
// Equivalent to above examples:
//
// Seq.iter (fun i -> printf "%d .. " i) {10 .. -1 .. 1} ; printfn "Liftoff!"
//
// {10 .. -1 .. 1} |> Seq.iter (fun i -> printf "%d .. " i) ; printfn "Liftoff!"
clojure
(dotimes [i 10]
(print (str (- 10 i) " .. ")))
(println "Liftoff!")
(dotimes [i 10]
(print (str (- 10 i) " .. ")))
(println "Liftoff!")
Submit a new solution for
python
,
csharp
,
fantom
,
fsharp
...
There are 15 other solutions in
additional
languages (
cpp
,
erlang
,
groovy
,
haskell
...)