Login
|
Signup
langref.org
-
python
,
clojure
, and
erlang
add..
all
cpp
csharp
fantom
fsharp
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 (FOR)
Display the string
"Hello"
five times like
"HelloHelloHelloHelloHello"
python
print "Hello" * 5
print "Hello" * 5
python
for i in range(5):
print "Hello"
for i in range(5):
print "Hello"
clojure
(dotimes [_ 5]
(print "Hello"))
(dotimes [_ 5]
(print "Hello"))
erlang
dotimes(5, fun () -> io:format("Hello") end).
-module(dotimes).
-export([start/0]).
start() ->
dotimes(5, fun () -> io:format("Hello") end).
dotimes(0, _) -> true;
dotimes(N, Action) -> Action(), dotimes(N - 1, Action).
erlang
lists:foreach(fun (_) -> io:format("Hello") end, lists:seq(1, 5)).
-module(dotimes).
-export([start/0]).
start() ->
lists:foreach(fun (_) -> io:format("Hello") end, lists:seq(1, 5)).
Submit a new solution for
python
,
clojure
, or
erlang
There are 32 other solutions in
additional
languages (
cpp
,
csharp
,
fantom
,
fsharp
...)