for(i = 1; i <= 10; i += 1)
    {
    show_message(string(i))
    i += 1
    if(i <= 10)
        continue
    }


package main

import "fmt"

func main() {
    for i := 1; i <= 10; i++ {
        fmt.Printf("%d", i)
        if i%5 == 0 {
            fmt.Printf("\n")
            continue
        }
        fmt.Printf(", ")
    }
}


for (i in 1..10) {
    print i
    if (i % 5 == 0) {
        println ()
        continue
    }
    print ', '
}


$ include "seed7_05.s7i";

const proc: main is func
  local
    var integer: number is 0;
  begin
    repeat
      incr(number);
      writeln(number)
    until number rem 6 = 0
  end func;


var value = 0;
do {
    say ++value;
} while (value % 6);


[| val |
  val: 0.
  [val: val + 1.
   print: val.
   val \\ 6 ~= 0] whileTrue
] do.


|val|
val := 0.
[
  val := val + 1.
  val displayNl.
] doWhile: [ (val rem: 6) ~= 0 ]


var i = 0;
do {
    print(++i);
} while (i % 6 != 0);


MODULE Downward;
  IMPORT InOut;

  VAR
    i: INTEGER;

BEGIN
  FOR i := 10 TO 0 BY -1 DO
    InOut.WriteInt(i, 2);
    InOut.WriteLn
  END
END Downward.


FOR i := 10 TO 0 BY -1 DO
  IO.PutInt(i);
END;


LOOPDOWN
 NEW I FOR I=10:-1:1 WRITE I WRITE:I'=1 ", "
 KILL I QUIT


Public Sub Main()
Dim i, j As Integer

For i = 1 To 5
   For j = 1 To i
      Print "*";
   Next
   Print
Next

End


pattern = ""
for(i = 1; i <= 5; i += 1)
    {
    for(j = 1; j <= i; j += 1)
        {
        pattern += "*"
        }
    pattern += "#"
    }
show_message(pattern)


import Control.Monad (forM)
main = forM [1..10] out
    where
      out x | x `mod` 5 == 0 = print x
            | otherwise = (putStr . (++", ") . show) x


for (i in 1...11) {
  Sys.print(i);
  if (i % 5 == 0) {
    Sys.print('\n');
    continue;
  }
  Sys.print(', ');
}


DO i = 1, 10
  IF( MOD(i, 5) == 1 ) THEN
      WRITE(Format="i3") i
    ELSE
      WRITE(APPend, Format=" ',', i3 ") i
    ENDIF
ENDDO


procedure main()
every writes(x := 1 to 10) do {
   if x % 5 = 0 then {
      write()
      next
      }
   writes(", ")
   }
end


con
  _clkmode = xtal1 + pll16x
  _clkfreq = 80_000_000

obj
  ser : "FullDuplexSerial.spin"

pub main | n
  ser.start(31, 30, 0, 115200)

  n := 0
  repeat
    n += 1
    ser.dec(n)
    ser.tx(32)
  while n // 6

  waitcnt(_clkfreq + cnt)
  ser.stop
  cogstop(0)


local n 0
local q 1
while `q' | mod(`n',6) {
	local q 0
	di `++n'
}


val = 0
do
    {
    Print(++val)
    } while (val % 6 isnt 0)


var val = 0
repeat {
  val += 1
  print(val)
} while val % 6 != 0


/* NetRexx */
options replace format comments java crossref savelog symbols nobinary

  say
  say 'Loops/Downward for'

  loop i_ = 10 to 0 by -1
    say i_.right(2)
    end i_


FOR i := 10 TO 0 BY -1 DO
  Out.Int(i,0);
END;


package main

import "fmt"

func main() {
    for i := 1; i <= 5; i++ {
        for j := 1; j <= i; j++ {
            fmt.Printf("*")
        }
        fmt.Printf("\n")
    }
}


for(i in (1..6)) {
    for(j in (1..i)) {
        print '*'
    }
    println ()
}


for(i,1,10,
    write(i)
    if(i%5 == 0, writeln() ; continue)
    write(" ,")
)


for(int i = 1;i <= 10; i++){
   System.out.print(i);
   if(i % 5 == 0){
      System.out.println();
      continue;
   }
   System.out.print(", ");
}


var output = "";
for (var i = 1; i <= 10; i++) {
  output += i;
  if (i % 5 == 0) {
    print(output);
    output = "";
    continue;
  }
  output += ", ";
}


templates doWhile
  0 -> #
  <> def val: $ + 1;
    $val -> !OUT::write
    $val -> \(<?($ mod 6 <~=0>)> $!\) -> #
end doWhile


proc do {body keyword expression} {
    if {$keyword eq "while"} {
       set expression "!($expression)"
    } elseif {$keyword ne "until"} {
       return -code error "unknown keyword \"$keyword\": must be until or while"
    }
    set condition [list expr $expression]
    while 1 {
       uplevel 1 $body
       if {[uplevel 1 $condition]} {
          break
       }
    }
    return
}

set i 0
do {puts [incr i]} while {$i % 6 != 0}


$$ MODE TUSCRIPT
var=0
LOOP
var=var+1, rest=var%6
PRINT var
IF (rest==0) EXIT
ENDLOOP


val=0
while true; do
  echo $((++val))
  [ $((val%6)) -eq 0 ] && break
done


L
   V a = random:(20)
   print(a)
   I a == 10
      L.break
   V b = random:(20)
   print(b)


for i = 10 downto 0 do
  Printf.printf "%d\n" i
done


100 FOR I=1 TO 5
110 FOR J=1 TO I
120 PRINT "*";
130 NEXT J
140 PRINT
150 NEXT I
160 END


import Control.Monad

main = do
  forM_ [1..5] $ \i -> do
    forM_ [1..i] $ \j -> do
      putChar '*'
    putChar '\n'


/* Loop/continue in jsish */
for (var i = 1; i <= 10; i++) {
    printf("%d", i);
    if (i % 5 == 0) {
        printf("\n");
        continue;
    }
    printf(", ");
}


for i in 1:10
    print(i)
    if i%5 == 0
        println()
        continue
    end
    print(", ")
end


// version 1.1.2

fun main(args: Array<String>) {
    for(i in 1 .. 10) {
        if (i % 5 == 0) {
            println(i)
            continue
        }
        print("$i, ")
    }
}


  int a = 0;

  do {
    a++;
    print(a.to_string() + "\n");
  }
  while ( a % 6 != 0);


Public Sub LoopDoWhile()
    Dim value As Integer
    value = 0
    Do
        value = value + 1
        Debug.Print value;
    Loop While value Mod 6 <> 0
End Sub


//  Basic @LOOP until: verb

@LOOP init:{@VAR n = 0} until:(n % 6 == 0)
{
     n++;
     @SAY n;
};


module main;
  integer  i;

  initial begin
    i = 1;

    $write(i);
    while(i % 6 != 0) begin
      i = i + 1;
      $write(i);
    end
  $finish ;
  end
endmodule


*        Loops Break               15/02/2017
LOOPBREA CSECT
         USING  LOOPBREA,R13       base register
         B      72(R15)            skip savearea
         DC     17F'0'             savearea
         STM    R14,R12,12(R13)    prolog
         ST     R13,4(R15)         " <-
         ST     R15,8(R13)         " ->
         LR     R13,R15            " addressability
LOOP     MVC    PG,=CL80' '        clean buffer
         LA     R8,PG              ipg=0
         BAL    R14,RANDINT        call randint
         C      R6,=F'10'          if k=10 then leave
         BE     ENDLOOP             <-- loop break
         BAL    R14,RANDINT        call randint
         XPRNT  PG,L'PG            print buffer
         B      LOOP               loop forever
ENDLOOP  XPRNT  PG,L'PG            print buffer
         L      R13,4(0,R13)       epilog
         LM     R14,R12,12(R13)    " restore
         XR     R15,R15            " rc=0
         BR     R14                exit
RANDINT  L      R5,RANDSEED        randint
         M      R4,=F'397204091'   "
         D      R4,=X'7FFFFFFF'    "
         ST     R4,RANDSEED        "
         LR     R5,R4              "
         SR     R4,R4              "
         D      R4,=F'20'          "
         LR     R6,R4              k=randint(20)
         XDECO  R6,XDEC            edit k
         MVC    0(4,R8),XDEC+8     output k
         LA     R8,4(R8)           ipg=ipg+4
         BR     R14                return
RANDSEED DC     F'39710831'        seed
PG       DS     CL80               buffer
XDEC     DS     CL12
         YREGS
         END    LOOPBREA


LoopBreakSub:	PHA			;push accumulator onto stack

BreakLoop:	JSR GenerateRandomNum	;routine not implemented
		;generates random number and puts in memory location RandomNumber

		LDA RandomNumber
		JSR DisplayAccumulator	;routine not implemented
		CMP #10
		BEQ Break
		JSR GenerateRandomNum
		LDA RandomNumber
		JSR DisplayAccumulator
		JMP BreakLoop

Break:		PLA			;restore accumulator from stack
		RTS			;return from subroutine


/* ARM assembly AARCH64 Raspberry PI 3B */
/*  program loopbreak64.s   */

/*******************************************/
/* Constantes file                         */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstantesARM64.inc"

/*********************************/
/* Initialized data              */
/*********************************/
.data
szMessEndLoop: .asciz "loop break with value : \n"
szMessResult:  .asciz "Resultat = @ \n"      // message result

.align 4
qGraine:  .quad 12345678
/*********************************/
/* UnInitialized data            */
/*********************************/
.bss
sZoneConv:               .skip 24
/*********************************/
/*  code section                 */
/*********************************/
.text
.global main
main:                          // entry of program
1:                             // begin loop
    mov x4,20
2:
    mov x0,19
    bl genereraleas            // generate number
    cmp x0,10                  // compar value
    beq 3f                     // break if equal
    ldr x1,qAdrsZoneConv       // display value
    bl conversion10            // call function with 2 parameter (x0,x1)
    ldr x0,qAdrszMessResult
    ldr x1,qAdrsZoneConv
    bl strInsertAtCharInc      // insert result at third @ character
    bl affichageMess           // display message final
    subs x4,x4,1                 // decrement counter
    bgt 2b                     // loop if greather
    b 1b                       // begin loop one

3:
    mov x2,x0                  // save value
    ldr x0,qAdrszMessEndLoop
    bl affichageMess           // display message
    mov x0,x2
    ldr x1,qAdrsZoneConv
    bl conversion10            // call function with 2 parameter (x0,x1)
    ldr x0,qAdrszMessResult
    ldr x1,qAdrsZoneConv
    bl strInsertAtCharInc      // insert result at third @ character
    bl affichageMess           // display message

100:                           // standard end of the program
    mov x0,0                   // return code
    mov x8,EXIT                // request to exit program
    svc 0                      // perform the system call

qAdrsZoneConv:            .quad sZoneConv
qAdrszMessResult:         .quad szMessResult
qAdrszMessEndLoop:        .quad szMessEndLoop

/***************************************************/
/*   Generation random number                  */
/***************************************************/
/* x0 contains limit  */
genereraleas:
    stp x1,lr,[sp,-16]!    // save  registers
    stp x2,x3,[sp,-16]!    // save  registers
    ldr x3,qAdrqGraine     // load graine
    ldr x2,[x3]
    lsr x1,x2,17           // see xorshift on wikipedia
    eor x2,x2,x1
    lsl x1,x2,31
    eor x2,x2,x1
    lsr x1,x2,8
    eor x1,x2,x1
    str x1,[x3]            // save graine for the next call
    udiv x1,x2,x0          // divide by value maxi
    msub x0,x1,x0,x2       // résult = remainder
100:                       // end function
    ldp x2,x3,[sp],16      // restaur  2 registers
    ldp x1,lr,[sp],16      // restaur  2 registers
    ret                    // return to address lr x30
/********************************************************************/
qAdrqGraine: .quad qGraine
/********************************************************/
/*        File Include fonctions                        */
/********************************************************/
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc"


PROC Main()
  BYTE v

  PrintE("Before loop")
  DO
    v=Rand(20)
    PrintBE(v)
    IF v=10 THEN
      EXIT
    FI
  OD
  PrintE("After loop")
RETURN


foreach (reverse 0..10) {
  print "$_\n";
}


for (i in 1...6) {
	for(j in 0...i) {
		Sys.print('*');
	}
	Sys.println('');
}


for let i 1; i <= 5; i++
  for let j 1; j <= i; j++
    print "*"
  endfor
  println ""
endfor


DO i = 1, 5
  DO j = 1, i
    WRITE(APPend) "*"
  ENDDO
  WRITE() ' '
ENDDO


{def loops_continue
 {lambda {:i}
  {if {> :i 10}
   then (end of loop)
   else {if {= :i 6} then {br}:i else :i}
        {if {= :i 10} then . else ,}
        {loops_continue {+ :i 1}}}}}
-> loops_continue

{loops_continue 0}
-> 0, 1, 2, 3, 4, 5,
6, 7, 8, 9, 10. (end of loop)


for .i of 10 {
    write .i
    if .i div 5 { writeln(); next }
    write ", "
}


loop(10) => {^
	loop_count
	loop_count % 5 ? ', ' | '\r'
	loop_count < 100 ? loop_continue
	'Hello, World!' // never gets executed
^}


str = ""
repeat with i = 1 to 10
  put i after str
  if i mod 5 = 0 then
    put RETURN after str
    next repeat
  end if
  put ", " after str
end repeat
put str


Dim i = 0
Do
    i += 1
    Console.WriteLine(i)
Loop Until i Mod 6 = 0


var v = 0
while (true) {
    v = v + 1
    System.print(v)
    if (v%6 == 0) break
}


fn main() {
	mut value := 0
	for {
		value++
		println(value)
                if value%6 != 0 {
                        break
                }
	}
}


extern _printf

section .data
    output db 0,0

section .text
global _main
_main:
    mov bl, 0
    looping:
        add bl, 0x31 ;0x30 to 0x39 is 0 to 9 in ASCII
        mov [output], bl
        sub bl, 0x30
        push output
        call _printf
        add esp, 4
        xor eax, eax
        xor edx, edx
        mov al, bl
        mov ecx, 6
        div ecx ; remainder is saved in edx
        cmp edx, 0
        jne looping ; if n & 6 != 0 do looping again
    xor eax, eax
    ret


with Ada.Text_IO;  use Ada.Text_IO;
with Ada.Numerics.Discrete_Random;

procedure Test_Loop_Break is
   type Value_Type is range 0..19;
   package Random_Values is new Ada.Numerics.Discrete_Random (Value_Type);
   use Random_Values;
   Dice : Generator;
   A, B : Value_Type;
begin
   loop
      A := Random (Dice);
      Put_Line (Value_Type'Image (A));
      exit when A = 10;
      B := Random (Dice);
      Put_Line (Value_Type'Image (B));
   end loop;
end Test_Loop_Break;


integer
main(void)
{
    integer a, b;

    while (1) {
        a = drand(19);
        o_integer(a);
        o_byte('\n');
        if (a == 10) {
            break;
        }

        b = drand(19);
        o_integer(b);
        o_byte('\n');
    }

    return 0;
}


'BEGIN' 'COMMENT' Loops/Break - ALGOL60 - 18/06/2018;
  'INTEGER' SEED;
  'INTEGER' 'PROCEDURE' RANDOM(N);
  'VALUE' N; 'INTEGER' N;
  'BEGIN'
    SEED:=(SEED*19157+12347) '/' 21647;
    RANDOM:=SEED-(SEED '/' N)*N+1
  'END' RANDOM;
  'INTEGER' I,J,K;
  SYSACT(1,6,120);SYSACT(1,8,60);SYSACT(1,12,1);'COMMENT' open print;
  SEED:=31567;
  J:=0;
  'FOR' I:=1, I+1 'WHILE' I 'LESS' 100 'DO' 'BEGIN'
    J:=J+1;
    K:=RANDOM(20);
    OUTINTEGER(1,K);
    'IF' J=8 'THEN' 'BEGIN'
       SYSACT(1,14,1);  'COMMENT' skip line;
       J:=0
    'END';
    'IF' K=10 'THEN' 'GOTO' LAB
  'END';
LAB:
  SYSACT(1,14,1);  'COMMENT' skip line;
'END'


(for (I 10 (ge0 I) (dec I))
   (println I) )


do i = 10 to 0 by -1;
   put skip list (i);
end;


To run:
Start up.
Put 11 into a counter.
Loop.
If the counter is below 0, break.
Convert the counter to a string.
Write the string on the console.
Repeat.
Wait for the escape key.
Shut down.

To decide if a counter is below a number:
Subtract 1 from the counter.
If the counter is less than the number, say yes.
Say no.


lvars i;
for i from 10 by -1 to 0 do
   printf(i, '%p\n');
endfor;


procedure main()
every i := 1 to 5 do {
   every 1 to i do
      writes("*")
   write()
   }
end


repeat with length running from 1 to 5:
	repeat with N running from 1 to length:
		say "*";
	say line break;


1.to 10 do { i : INTEGER;
  i.print;
  (i % 5 = 0).if { '\n'.print; } else { ','.print; };
};


repeat with n = 1 to 10
    put n
    if n is 5 then put return
    if n < 10 and n is not 5 then put ","
end repeat


for i = 1, 10 do
    io.write( i )
    if i % 5 == 0 then
        io.write( "\n" )
    else
    	io.write( ", " )
    end
end


Module Checkit {
      \\ A For {} loop
      For i=1 to 10 {
            Print i;
            if i mod 5 Else Print : continue
            Print ",";
      }
      Print i=11
      \\ A For Next loop
      For i=1 to 10
            Print i;
            if i mod 5 Else Print : continue
            Print ",";
      Next i
      Print i=11
      \\ A for loop using  a block and a Loop statement
      i=0
      {     i++
            if i>10  then Exit
            loop
            Print i;
            if i mod 5 Else Print : continue
            Print ",";
       }
      Print i=11
      \\ as above but end value for i=10 not 11
      i=0
      {     i++
            if i<10  then loop
            Print i;
            if i mod 5 Else Print : continue
            Print ",";
       }
      Print i=10  ' not 11 but 10
}
Checkit


for i from 1 to 10 do
        printf( "%d", i );
        if irem( i, 5 ) = 0 then
                printf( "\n" );
                next
        end if;
        printf( ", " )
end do:


code CrLf=9, IntOut=11;
int V;
[V:= 0;
repeat  V:= V+1;
        IntOut(0, V);  CrLf(0);
until   rem(V/6) = 0;
]


val = 0;
do {
    val++;
    write, val;
} while(val % 6 != 0);


val := 0;
do {
    val+=1;
    val.print(" ");
} while(val % 6 != 0);


const std = @import("std");

pub fn main() !void {
    var a: u8 = 0;
    // no do-while in syntax, trust the optimizer to do
    // correct Loop inversion https://en.wikipedia.org/wiki/Loop_inversion
    // If the variable `alive` is independent to other variables and not in
    // diverging control flow, then the optimization is possible in general.
    var alive = true;
    while (alive == true or a % 6 != 0) {
        alive = false;
        a += 1;
        try std.io.getStdOut().writer().print("{d}\n", .{a});
    }
}


main: (
    INT a, b;
    INT seed := 4; # chosen by a fair dice roll, guaranteed to be random c.f. http://xkcd.com/221/ #
    # first random; #
    WHILE
        a := ENTIER (next random(seed) * 20);
        print((a));
  # WHILE # NOT (a = 10) DO
        b := ENTIER (next random(seed) * 20);
        print((b, new line))
    OD;
    print(new line)
)


repeat
	set a to random number from 0 to 19
	if a is 10 then
		log a
		exit repeat
	end if
	set b to random number from 0 to 19
	log a & b
end repeat


(point break
  (while t
    (let x (rand 20)
      (prn "a: " x)
      (if (is x 10)
        (break)))
    (prn "b: " (rand 20))))


rfor(Hi,Lo,Hi) :- Hi >= Lo.
rfor(Hi,Lo,Val) :- Hi > Lo, H is Hi - 1, !, rfor(H,Lo,Val).

reverse_iter :-
  rfor(10,0,Val), write(Val), nl, fail.
reverse_iter.


for i in xrange(10, -1, -1):
    print i


#lang racket

(for ([i (in-range 10 -1 -1)])
  (displayln i))


for (int i = 0; i < 5; i++) {
   for (int j = 0; j <= i; j++) {
      System.out.print("*");
   }
   System.out.println();
}


/* There is no "continue" in Maxima, the easiest is using a "if" instead */
block(
   [s: ""],
   for n thru 10 do (
      s: sconcat(s, n),
      if mod(n, 5) = 0 then (
         ldisp(s),
         s: ""
      ) else (
         s: sconcat(s, ", ")
      )
   )
)$


for i in 1 to 10 do
(
    format "%" i
    if mod i 5 == 0 then
    (
        format "\n"
        continue
    )   continue
    format ", "
)


string s; s := "";
for i = 1 step 1 until 10:
if i mod 5 = 0:
  s := s & decimal i & char10;
else:
  s := s & decimal i & ", "
fi; endfor
message s;
end


/* ARM assembly Raspberry PI  */
/*  program loopbreak.s   */

/* Constantes    */
.equ STDOUT, 1     @ Linux output console
.equ EXIT,   1     @ Linux syscall
.equ WRITE,  4     @ Linux syscall

/*********************************/
/* Initialized data              */
/*********************************/
.data
szMessEndLoop: .asciz "loop break with value : \n"
szMessResult:  .ascii "Resultat = "      @ message result
sMessValeur:   .fill 12, 1, ' '
                   .asciz "\n"
.align 4
iGraine:  .int 123456
/*********************************/
/* UnInitialized data            */
/*********************************/
.bss
/*********************************/
/*  code section                 */
/*********************************/
.text
.global main
main:                @ entry of program
    push {fp,lr}      @ saves 2 registers
1:    @ begin loop
    mov r4,#20
2:
    mov r0,#19
    bl genereraleas               @ generate number
    cmp r0,#10                       @ compar value
    beq 3f                         @ break if equal
    ldr r1,iAdrsMessValeur     @ display value
    bl conversion10             @ call function with 2 parameter (r0,r1)
    ldr r0,iAdrszMessResult
    bl affichageMess            @ display message
    subs r4,#1                   @ decrement counter
    bgt 2b                      @ loop if greather
    b 1b                          @ begin loop one

3:
    mov r2,r0             @ save value
    ldr r0,iAdrszMessEndLoop
    bl affichageMess            @ display message
    mov r0,r2
    ldr r1,iAdrsMessValeur
    bl conversion10       @ call function with 2 parameter (r0,r1)
    ldr r0,iAdrszMessResult
    bl affichageMess            @ display message

100:   @ standard end of the program
    mov r0, #0                  @ return code
    pop {fp,lr}                 @restaur 2 registers
    mov r7, #EXIT              @ request to exit program
    svc #0                       @ perform the system call

iAdrsMessValeur:          .int sMessValeur
iAdrszMessResult:         .int szMessResult
iAdrszMessEndLoop:        .int szMessEndLoop
/******************************************************************/
/*     display text with size calculation                         */
/******************************************************************/
/* r0 contains the address of the message */
affichageMess:
    push {r0,r1,r2,r7,lr}      @ save  registres
    mov r2,#0                  @ counter length
1:      @ loop length calculation
    ldrb r1,[r0,r2]           @ read octet start position + index
    cmp r1,#0                  @ if 0 its over
    addne r2,r2,#1            @ else add 1 in the length
    bne 1b                    @ and loop
                                @ so here r2 contains the length of the message
    mov r1,r0        			@ address message in r1
    mov r0,#STDOUT      		@ code to write to the standard output Linux
    mov r7, #WRITE             @ code call system "write"
    svc #0                      @ call systeme
    pop {r0,r1,r2,r7,lr}        @ restaur des  2 registres */
    bx lr                       @ return
/******************************************************************/
/*     Converting a register to a decimal                                 */
/******************************************************************/
/* r0 contains value and r1 address area   */
conversion10:
    push {r1-r4,lr}    @ save registers
    mov r3,r1
    mov r2,#10

1:	   @ start loop
    bl divisionpar10 @ r0 <- dividende. quotient ->r0 reste -> r1
    add r1,#48        @ digit
    strb r1,[r3,r2]  @ store digit on area
    sub r2,#1         @ previous position
    cmp r0,#0         @ stop if quotient = 0 */
    bne 1b	          @ else loop
    @ and move spaces in first on area
    mov r1,#' '   @ space
2:
    strb r1,[r3,r2]  @ store space in area
    subs r2,#1       @ @ previous position
    bge 2b           @ loop if r2 >= zéro

100:
    pop {r1-r4,lr}    @ restaur registres
    bx lr	          @return
/***************************************************/
/*   division par 10   signé                       */
/* Thanks to http://thinkingeek.com/arm-assembler-raspberry-pi/*
/* and   http://www.hackersdelight.org/            */
/***************************************************/
/* r0 dividende   */
/* r0 quotient */
/* r1 remainder  */
divisionpar10:
  /* r0 contains the argument to be divided by 10 */
    push {r2-r4}   /* save registers  */
    mov r4,r0
    mov r3,#0x6667   @ r3 <- magic_number  lower
    movt r3,#0x6666  @ r3 <- magic_number  upper
    smull r1, r2, r3, r0   @ r1 <- Lower32Bits(r1*r0). r2 <- Upper32Bits(r1*r0)
    mov r2, r2, ASR #2     /* r2 <- r2 >> 2 */
    mov r1, r0, LSR #31    /* r1 <- r0 >> 31 */
    add r0, r2, r1         /* r0 <- r2 + r1 */
    add r2,r0,r0, lsl #2   /* r2 <- r0 * 5 */
    sub r1,r4,r2, lsl #1   /* r1 <- r4 - (r2 * 2)  = r4 - (r0 * 10) */
    pop {r2-r4}
    bx lr                  /* leave function */

/***************************************************/
/*   Generation random number                  */
/***************************************************/
/* r0 contains limit  */
genereraleas:
    push {r1-r4,lr}    @ save registers
    ldr r4,iAdriGraine
    ldr r2,[r4]
    ldr r3,iNbDep1
    mul r2,r3,r2
    ldr r3,iNbDep1
    add r2,r2,r3
    str r2,[r4]     @ maj de la graine pour l appel suivant

    mov r1,r0        @ divisor
    mov r0,r2        @ dividende
    bl division
    mov r0,r3       @  résult = remainder

100:                @ end function
    pop {r1-r4,lr}   @ restaur registers
    bx lr            @ return
/********************************************************************/
iAdriGraine: .int iGraine
iNbDep1: .int 0x343FD
iNbDep2: .int 0x269EC3
/***************************************************/
/* integer division unsigned                       */
/***************************************************/
division:
    /* r0 contains dividend */
    /* r1 contains divisor */
    /* r2 returns quotient */
    /* r3 returns remainder */
    push {r4, lr}
    mov r2, #0                @ init quotient
    mov r3, #0                @ init remainder
    mov r4, #32               @ init counter bits
    b 2f
1:          @ loop
    movs r0, r0, LSL #1     @ r0 <- r0 << 1 updating cpsr (sets C if 31st bit of r0 was 1)
    adc r3, r3, r3           @ r3 <- r3 + r3 + C. This is equivalent to r3 <- (r3 << 1) + C
    cmp r3, r1               @ compute r3 - r1 and update cpsr
    subhs r3, r3, r1        @ if r3 >= r1 (C=1) then r3 <- r3 - r1
    adc r2, r2, r2           @ r2 <- r2 + r2 + C. This is equivalent to r2 <- (r2 << 1) + C
2:
    subs r4, r4, #1          @ r4 <- r4 - 1
    bpl 1b                  @ if r4 >= 0 (N=0) then loop
    pop {r4, lr}
    bx lr


print(Template("""{% set sum = 0 %}
                  {% for i in range(6) %}
                        {{ sum }}{% set sum = sum + i %}
                  {%- endfor %}""").render())


# Single-string version using explicit nested loops:
def demo(m):
  reduce range(0;m) as $i
    (""; reduce range(0;$i) as $j
           (.; . + "*" )  + "\n" ) ;

# Stream of strings:
def demo2(m):
  range(1;m)
  | reduce range(0;.) as $j (""; . + "*");

# Variation of demo2 using an implicit inner loop:
def demo3(m): range(1;m) | "*" * . ;


FOR i := 1 TO 10 DO
  IO.PutInt(i);
  IF i MOD 5 = 0 THEN
    IO.Put("\n");
    RETURN;
  END;
  IO.Put(", ");
END;


s = "";
for i in [1..10]
  s += tostr(i);
  if (i % 5 == 0)
    player:tell(s);
    s = "";
    continue;
  endif
  s += ", ";
endfor


/**
 Loops/Continue in Neko
 Tectonics:
   nekoc loops-continue.neko
   neko loops-continue
*/

var index = 0;

while index < 10 {
  index += 1;
  $print(index);
  if $not($istrue(index % 5)) {
    $print("\n");

    continue;

  }
  $print(", ");
}


using System;
using System.Console;
using Nemerle.Imperative;

module Continue
{
    Main() : void
    {
        foreach (i in [1 .. 10])
        {
            Write(i);
            when (i % 5 == 0) {WriteLine(); continue;}
            Write(", ");
        }
    }
}


/* NetRexx */
options replace format comments java crossref savelog symbols nobinary

  say
  say 'Loops/Continue'

  nul = '\-'
  loop i_ = 1 to 10
    say i_.right(2) || nul
    if i_ // 5 = 0 then do
      say
      iterate i_
      end
    say ', ' || nul

    end i_


while ø [
    a: random 0 19
    prints [a ""]
    if a=10 -> break

    b: random 0 19
    print b
]
print ""


Loop
{
  Random, var, 0, 19
  output = %output%`n%var%
  If (var = 10)
    Break
  Random, var, 0, 19
  output = %output%`n%var%
}
MsgBox % output


rng ::= a pRNG;
checked : [0..19];
Do [
    checked : = rng's next [0..19];
    Print: “checked”;
] while checked ≠ 10 alternate with [
    Print: " " ++ “rng's next [0..19]” ++ "\n";
];


class MAIN is
  main is
    i:INT;
    loop i := 10.downto!(0);
       #OUT  + i + "\n";
    end;
  end;
end;


for(i <- 10 to 0 by -1) println(i)
//or
10 to 0 by -1 foreach println


for i in 1:5
    for j in 1:i
        print("*")
    end
    println()
end


:" x{p}:*y means repeat {p} x times starting at y "

5{x{.d(0c*);x}:*0;.p("");x+1}:*1

:" But you would not do it like this! "
:" You would reshape 0c* to the desired length "
:" in a function and then iterate that function "
:" over a vector of numbers: "

{.p(x:^0c*)}'1+!5


fun main(args: Array<String>) {
    (1..5).forEach {
        (1..it).forEach { print('*') }
        println()
    }
}


for i in 1..10:
  if i mod 5 == 0:
    echo i
    continue
  stdout.write i, ", "


10 FOR I=1 TO 10
20 PRINT I;
30 IF I-I/5*5=0 THEN PRINT :GOTO 50"CONTINUE
40 PRINT ",";
50 NEXT


class Continue {
  function : Main(args : String[]) ~ Nil {
    for(i := 1; i <= 10; i += 1;) {
      if(i = 5) {
        "{$i}, "->PrintLine();
        continue;
      };
      "{$i}, "->Print();
    };
  }
}


BEGIN {
	for (;;) {
		print n = int(rand() * 20)
		if (n == 10)
			break
		print int(rand() * 20)
	}
}


While 1
 rand^20→A
 Disp A▶Dec
 ReturnIf A=10
 rand^20→B
 Disp B▶Dec,i
End


FOR I = 0 TO 1 STEP 0 : N = INT(RND(1) * 20) : PRINT " "N; : IF N <> 10 THEN ? ","INT(RND(1) * 20); : NEXT


for i range 10 downto 0 do
  writeln(i);
end for;


BEGIN
    Integer i;
    for i := 10 step -1 until 0 do
    BEGIN
        OutInt(i, 2);
        OutImage
    END
END


10 to: 0 by: -1 do:[:aNumber |
  aNumber displayNl.
].

10 downTo: 0 do:[:eachNumber |
  eachNumber displayNl.
]


        COUNT = 10
LOOP    OUTPUT = COUNT
        COUNT = COUNT - 1
        GE(COUNT, 0)     :S(LOOP)
END


{def loops_for
 {lambda {:i :n}
  {if {>= :i :n}
   then (end of loop)
   else {br}{S.map {lambda {} *} {S.serie 0 :i}}
        {loops_for {+ :i 1} :n}}}}
-> loops_for

{loops_for 0 5}
->
*
* *
* * *
* * * *
* * * * * (end of loop)

a simpler way, using {S.map function {S.serie start end [step]}

{S.map {lambda {:i} {br}
{S.map {lambda {:i} *}
{S.serie 1 :i}}}
{S.serie 1 5}}
->
 *
 * *
 * * *
 * * * *
 * * * * *


# for i = 1 to 10 do
    try
      print_int i;
      if (i mod 5) = 0 then raise Exit;
      print_string ", "
    with Exit ->
      print_newline()
  done
  ;;
1, 2, 3, 4, 5
6, 7, 8, 9, 10
- : unit = ()


v = "";
for i = 1:10
  v = sprintf("%s%d", v, i);
  if ( mod(i, 5) == 0 )
    disp(v)
    v = "";
    continue
  endif
  v = sprintf("%s, ", v);
endfor


: loopCont
| i |
   10 loop: i [
      i dup print 5 mod ifZero: [ printcr continue ]
      "," .
      ] ;


(let loop ((i 1))
   (when (less? i 11)
      (call/cc (lambda (continue)
         (display i)
         (when (zero? (mod i 5))
            (print)
            (continue #f))
         (display ", ")))
      (loop (+ i 1))))


@echo off
:loop
  set /a N=%RANDOM% %% 20
  echo %N%
  if %N%==10 exit /b
  set /a N=%RANDOM% %% 20
  echo %N%
goto loop


      REPEAT
        num% = RND(20)-1
        PRINT num%
        IF num%=10 THEN EXIT REPEAT
        PRINT RND(20)-1
      UNTIL FALSE


s = 1  /* seed of the random number generator */
scale = 0

/* Random number from 0 to 20. */
define r() {
	auto a
	while (1) {
		/* Formula (from POSIX) for random numbers of low quality. */
		s = (s * 1103515245 + 12345) % 4294967296
		a = s / 65536       /* a in [0, 65536) */
		if (a >= 16) break  /* want a >= 65536 % 20 */
	}
	return (a % 20)
}

while (1) {
	n = r()
	n    /* print 1st number */
	if (n == 10) break
	r()  /* print 2nd number */
}
quit


++++++++++>++++++++++!/- @!\[email protected]\[email protected]@@[email protected]#   atoi
    \n      counter  #\?>.</  \ @@@[email protected]+++++#   itoa
                       loop


for var i = 10; i >= 0; i-- {
    print(i);
}


con
  _clkmode = xtal1 + pll16x
  _clkfreq = 80_000_000

obj
  ser : "FullDuplexSerial.spin"

pub main | n
  ser.start(31, 30, 0, 115200)

  repeat n from 10 to 0
    ser.dec(n)
    ser.tx(32)

  waitcnt(_clkfreq + cnt)
  ser.stop
  cogstop(0)


forvalues n=10(-1)0 {
        display `n'
}

forvalues n=10 9 to 0 {
        display `n'
}

foreach n of numlist 10/0 {
        display `n'
}


for i in stride(from: 10, through: 0, by: -1) {
  println(i)
}


: cr  "\n" . ;      : dip  swap '_ set execute _ ;
: nip  swap drop ;  : last  -1 extract nip ;
: times
    swap iota '_ set
    do   dup 'execute dip _ last 0 == if break then
    loop drop ;

: concat  "" join ;
'* 1 5 "2dup reshape concat . cr 1 +" times


for I in 1..10 continue:C do
   {System.print I}
   if I mod 5 == 0 then
      {System.printInfo "\n"}
      {C}
   end
   {System.printInfo ", "}
end


for(n=1,10,
  print1(n);
  if(n%5 == 0, print();continue);
  print1(", ")
)


int main(){
	time_t t;
	int a, b;
	srand((unsigned)time(&t));
	for(;;){
		a = rand() % 20;
		printf("%d\n", a);
		if(a == 10)
			break;
		b = rand() % 20;
		printf("%d\n", b);
	}
	return 0;
}


class Program
{
    static void Main(string[] args)
    {
        Random random = new Random();
        while (true)
        {
            int a = random.Next(20);
            Console.WriteLine(a);
            if (a == 10)
                break;
            int b = random.Next(20)
            Console.WriteLine(b);
        }

        Console.ReadLine();
    }
}


#include <iostream>
#include <ctime>
#include <cstdlib>

int main(){
	srand(time(NULL)); // randomize seed
	while(true){
		const int a = rand() % 20; // biased towards lower numbers if RANDMAX % 20 > 0
		std::cout << a << std::endl;
		if(a == 10)
			break;
		const int b = rand() % 20;
		std::cout << b << std::endl;
	}
	return 0;
}


for {set i 10} {$i >= 0} {incr i -1} {
    puts $i
}
# puts "We have liftoff!"


$$ MODE TUSCRIPT
LOOP n=10,0,-1
 PRINT n
ENDLOOP


i=10
while test $i -ge 0; do
	echo $i
	i=`expr $i - 1`
done

# or

jot - 10 0 -1

# or

seq 10 -1 0


yes '' | cat -n | head -n 11 | while read n; do
	expr $n - 1
done | tail -r


      .ORIG      0x3000

      AND        R1,R1,0
      ADD        R1,R1,1
      AND        R5,R5,0
      ADD        R5,R5,5
      NOT        R5,R5

LOOPI LD         R0,STAR
      AND        R2,R2,0
      ADD        R3,R1,0

LOOPJ OUT
      ADD        R2,R2,1
      NOT        R4,R2
      ADD        R4,R3,R4
      BRZP       LOOPJ

      LD         R0,LF
      OUT

      ADD        R1,R1,1
      ADD        R4,R1,R5
      BRN        LOOPI

      HALT

STAR  .FILL      0x2A
LF    .FILL      0x0A

      .END


for {set i 1} {$i <= 5} {inc i} {
    for {set j 1} {$j <= $i} {inc j} {
        write "*"
    }
    print
}


repeat with i = 1 to 5
  str = ""
  repeat with j = 1 to i
    put "*" after str
  end repeat
  put str
end repeat


with javascript_semantics
for i=1 to 10 do
    printf(1,"%d", i)
    if remainder(i,5)=0 then
        printf(1, "\n")
        continue
    end if
    printf(1,", ")
end for


main =>
    foreach (I in 1..10)
        printf("%d", I),
        if (I mod 5 == 0) then
            nl
        else
            printf(", ")
        end,
    end.


use Random;

var r = new RandomStream();
while true {
        var a = floor(r.getNext() * 20):int;
        writeln(a);
        if a == 10 then break;
        var b = floor(r.getNext() * 20):int;
        writeln(b);
}
delete r;


(loop [[a b & more] (repeatedly #(rand-int 20))]
  (println a)
  (when-not (= 10 a)
    (println b)
    (recur more)))


decl int i
for (set i 10) (> i -1) (dec i)
	out i endl console
end for


for (int i = 10; i >= 0; --i)
    stdout.printf("%d\n", i);


For i = 10 To 0 Step -1
   Debug.Print i
Next i


module main;
  integer  i;

  initial begin

    for(i = 10; i >= 0; i = i - 1)  $write(i);
  $finish ;
  end
endmodule


1.to 5 do { i : INTEGER;
  1.to i do { dummy : INTEGER;
    '*'.print;
  };
  '\n'.print;
};


put 0 into n
repeat for 5 times
  add 1 to n
  repeat for n times
    put "*"
  end repeat
  put return
end repeat


for [i 1 5] [repeat :i [type "*] (print)]
repeat 5 [repeat repcount [type "*] (print)]


int main(){
   for(int i = 1; i <= 10; i++){
      write(sprintf("%d",i));
      if(i % 5 == 0){
         write("\n");
         continue;
      }
      write(", ");
   }
}


loop:
do i = 1 to 10;
   put edit (i) (f(3));
   if mod(i,5) = 0 then do; put skip; iterate loop; end;
   put edit (', ') (a);
end;


To run:
Start up.
Demonstrate continue.
Wait for the escape key.
Shut down.

To demonstrate continue:
If a counter is past 10, exit.
Convert the counter to a string.
Write the string on the console without advancing.
If the counter is evenly divisible by 5, write "" on the console; repeat.
Write ", " on the console without advancing.
Repeat.


lvars i;
for i from 1 to 10 do
   printf(i, '%p');
   if i rem 5 = 0 then
       printf('\n');
       nextloop;
   endif;
   printf(', ')
endfor;


       IDENTIFICATION DIVISION.
       PROGRAM-ID. Random-Nums.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  Num  PIC Z9.

       PROCEDURE DIVISION.
       Main.
           PERFORM FOREVER
               PERFORM Generate-And-Display-Num

               IF Num = 10
                   EXIT PERFORM
               ELSE
                   PERFORM Generate-And-Display-Num
               END-IF
           END-PERFORM

           GOBACK
           .

       Generate-And-Display-Num.
           COMPUTE Num =  FUNCTION REM(FUNCTION RANDOM * 100, 20)
           DISPLAY Num
           .


loop
  print a = Math.random() * 20 // 1
  break if a == 10
  print Math.random() * 20 // 1


<Cfset randNum = 0>
<cfloop condition="randNum neq 10">
  <Cfset randNum = RandRange(0, 19)>
  <Cfoutput>#randNum#</Cfoutput>
  <Cfif randNum eq 10><cfbreak></Cfif>
  <Cfoutput>#RandRange(0, 19)#</Cfoutput>
  <Br>
</cfloop>


For i = 10 To 0 Step -1
    Console.WriteLine(i)
Next


for (i in 10..0) System.write("%(i) ")
System.print()


include c:\cxpl\codes;          \intrinsic 'code' declarations
int I;
for I:= 10 downto 0 do
        [IntOut(0, I); CrLf(0)]


org &1000

LD A,'1'
CALL &BB5A
LD A,'0'
CALL &BB5A

LD B,9
LD A,'9'

for:
CALL &BB5A
DEC A
DJNZ for

LD A,'0'
JP &BB5A	;its RET returns to BASIC for us.


for i=1,5 do
  for j=1,i do
    io.write("*")
  end
  io.write("\n")
end


For i=1 to 5
      For j=1 to i
            Print "*";
      Next j
      Print
Next i
Print "End1"
For i=1 to 5 {
      For j=1 to i {
            Print "*";
      }
      Print
}
Print "End2"


for ($i = 1; $i -le 10; $i++) {
    Write-Host -NoNewline $i
    if ($i % 5 -eq 0) {
        Write-Host
        continue
    }
    Write-Host -NoNewline ", "
}


:- initialization(main).

print_list(Min, Max) :-
    Min < Max,
    write(Min),
    Min1 is Min + 1,
    (
        Min mod 5 =:= 0
        -> nl
        ; write(',')
    ),
    print_list(Min1, Max).

print_list(Max, Max) :-
    write(Max),
    nl.

main :-
    print_list(1, 10).


for i in xrange(1,11):
    if i % 5 == 0:
        print i
        continue
    print i, ",",


10 times
  [ i^ 1+ dup echo
    5 mod 0 = iff
      cr done
    say ", " ]


(loop for a = (random 20)
      do (print a)
      until (= a 10)
      do (print (random 20)))


import std.stdio, std.random;

void main() {
    while (true) {
        int r = uniform(0, 20);
        write(r, " ");
        if (r == 10)
            break;
        write(uniform(0, 20), " ");
    }
}


1 ss  [s = seed of the random number generator]sz
0k    [scale = 0]sz

[Function r: Push a random number from 0 to 20.]sz
[
 [2Q]SA
 [
  [Formula (from POSIX) for random numbers of low quality.]sz
  ls 1103515245 * 12345 + 4294967296 % d ss  [Compute next s]sz
  65536 /     [it = s / 65536]sz
  d 16 !>A    [Break loop if 16 <= it]sz
  sz 0 0 =B   [Forget it, continue loop]sz
 ]SB 0 0 =B
 20 %         [Push it % 20]sz
 LA sz LB sz  [Restore A, B]sz
]sr

[2Q]sA
[
 0 0 =r p     [Print 1st number.]sz
 10 =A        [Break if 10 == it.]sz
 0 0 =r p sz  [Print 2nd number.]sz
 0 0 =B       [Continue loop.]sz
]sB 0 0 =B


const std = @import("std");

pub fn main() !void {
    var i: u8 = 11;
    while (i > 0) {
        i -= 1;
        try std.io.getStdOut().writer().print("{d}\n", .{i});
    }
}


all: line-5

ILIST != jot 5
.for I in $(ILIST)

line-$(I): asterisk-$(I)-$(I)
	@echo

JLIST != jot $(I)
. for J in $(JLIST)

.  if "$(J)" == "1"
.   if "$(I)" == "1"
asterisk-1-1:
.   else
IM != expr $(I) - 1
asterisk-$(I)-1: line-$(IM)
.   endif
.  else
JM != expr $(J) - 1
asterisk-$(I)-$(J): asterisk-$(I)-$(JM)
.  endif
	@printf \*

. endfor
.endfor


> for i to 5 do to i do printf( "*" ) end; printf( "\n" ) end;
*
**
***
****
*****


#lang racket

;; Idiomatic way
(for ([i (in-range 1 11)])
  (if (= (remainder i 5) 0)
      (printf "~a~n" i)
      (printf "~a, " i)))

;; Forces a skip, but not idiomatic because
;; the logic is less obvious
(for ([i (in-range 1 11)]
      #:unless (and (= (remainder i 5) 0)
                    (printf "~a~n" i)))
  (printf "~a, " i))


for 1 .. 10 {
    .print;
    if $_ %% 5 {
        print "\n";
        next;
    }
    print ', ';
}


rebol [
	Title: "Loop/Continue"
	URL: http://rosettacode.org/wiki/Loop/Continue
]

; REBOL does not provide a 'continue' word for loop constructs,
; however, you may not even miss it:

print "One liner (compare to ALGOL 68 solution):"
repeat i 10 [prin rejoin [i  either 0 = mod i 5 [crlf][", "]]]

print [crlf "Port of ADA solution:"]
for i 1 10 1 [
	prin i
	either 0 = mod i 5 [
		prin newline
	][
		prin ", "
	]
]


program Project5;

{$APPTYPE CONSOLE}

var
  num:Integer;
begin
  Randomize;
  while true do
  begin
    num:=Random(20);
    Writeln(num);
    if num=10 then break;
  end;
end.


while True do begin
   var num := RandomInt(20);
   PrintLn(num);
   if num=10 then Break;
end;


while (true) {
    def a := entropy.nextInt(20)
    print(a)
    if (a == 10) {
        println()
        break
    }
    println(" ", entropy.nextInt(20))
}


n=5;
For[i=1,i<=5,i++,
 string="";
 For[j=1,j<=i,j++,string=string<>"*"];
 Print[string]
]


for i = (1:5)
    output = [];
    for j = (1:i)
        output = [output '*'];
    end
    disp(output);
end


for i thru 5 do (
   s: "",
   thru i do s: sconcat(s, "*"),
   print(s)
);


/*REXX program  illustrates  an example of a   DO   loop with an  ITERATE  (continue).  */

  do j=1  for 10                                 /*this is equivalent to:  DO J=1 TO 10 */
  call charout ,  j                              /*write the integer to the terminal.   */
  if j//5\==0  then do                           /*Not a multiple of five?   Then ···   */
                    call charout , ", "          /*  write a comma to the terminal, ··· */
                    iterate                      /* ··· & then go back for next integer.*/
                    end
  say                                            /*force REXX to display on next line.  */
  end   /*j*/
                                                 /*stick a fork in it,  we're all done. */


for i = 1 TO 10
   see i
   if i % 5 = 0
      see nl
      loop
   ok
   see ", "
next


for i in 1..10 do
   print i
   if i % 5 == 0 then
      puts
      next
   end
   print ', '
end


fn main() {
    for i in 1..=10 {
        print!("{}", i);
        if i % 5 == 0 {
            println!();
            continue;
        }
        print!(", ");
    }
}


repeat
  a = random 20
  print a
  until a = 10
  print random 20
.


example
		-- Eiffel example code
	local
		n: INTEGER
		r: RANDOMIZER
	do
		from
			create r
			n := r.random_integer_in_range (0 |..| 19)
		until
			n = 10
		loop
			n := r.random_integer_in_range (0 |..| 19)
		end
	end


open datetime random monad io

loop = loop' 1
       where loop' n t = do
                dt <- datetime.now
                seed <- return <| toInt <| (ticks <| dt) * n
                r <- return $ rnd seed 0 19
                putStrLn (show r)
                if r <> t then loop' (n + 1) t else return ()

loop 10 ::: IO


defmodule Loops do
  def break, do: break(random)

  defp break(10), do: IO.puts 10
  defp break(r) do
    IO.puts "#{r},\t#{random}"
    break(random)
  end

  defp random, do: Enum.random(0..19)
end

Loops.break


for i in 1 to 5 do
(
    line = ""
    for j in 1 to i do
    (
        line += "*"
    )
    format "%\n" line
)


:- module loops_for.
:- interface.

:- import_module io.
:- pred main(io::di, io::uo) is det.

:- implementation.
:- import_module int.

main(!IO) :-
   int.fold_up(outer_loop_body, 1, 5, !IO).

:- pred outer_loop_body(int::in, io::di, io::uo) is det.

outer_loop_body(I, !IO) :-
   int.fold_up(inner_loop_body, 1, I, !IO),
   io.nl(!IO).

:- pred inner_loop_body(int::in, io::di, io::uo) is det.

inner_loop_body(_, !IO) :-
   io.write_char('*', !IO).


for i in range(1,5)
    s = ""
    for j in range(1, i)
        s = s + "*"
    end for
    print s
end for


class MAIN is
  main is
    i:INT;
    loop i := 1.upto!(10);
      #OUT + i;
      if i%5 = 0 then
        #OUT + "\n";
      else
        #OUT + ", ";
      end;
    end;
  end;
end;


for (i <- 1 to 10) {
  print(i)
  if (i % 5 == 0) println() else print(", ")
  }


(define (loop i)
  (if (> i 10) 'done
      (begin
       (display i)
       (cond ((zero? (modulo i 5))
              (newline) (loop (+ 1 i)))
             (else (display ", ")
                   (loop (+ 1 i)))))))


for i=1:10
    printf("%2d ",i)
    if modulo(i,5)~=0 then
      printf(", ")
      continue
    end
    printf("\n")
end


for i in (1..10) {
    print i
    if (i %% 5) {
        print "\n"
        next
    }
    print ', '
}


%% Implemented by Arjun Sunel
-module(forever).
-export([main/0, for/0]).

main() ->
	for().

for() ->
	K = random:uniform(19),
        io:fwrite( "~p ", [K] ),
	if  K==10 ->
		ok;
	true ->
		M = random:uniform(19),
		io:format("~p~n",[M]),
   		for()
	end.


LOOP
    A=INT(RND(1)*20)
    PRINT(A)
    IF A=10 THEN EXIT LOOP END IF !EXIT FOR works the same inside FOR loops
    PRINT(INT(RND(1)*20))
END LOOP


integer i
while 1 do
    i = rand(20) - 1
    printf(1, "%g ", {i})
    if i = 10 then
        exit
    end if
    printf(1, "%g ", {rand(20)-1})
end while


MODULE For;
  IMPORT InOut;

  VAR
    i, j: INTEGER;

BEGIN
  FOR i := 1 TO 5 DO
    FOR j := 1 TO i DO
      InOut.Write('*');
    END;
    InOut.WriteLn
  END
END For.


MODULE Stars EXPORTS Main;

IMPORT IO;

BEGIN
  FOR i := 1 TO 5 DO
    FOR j := 1 TO i DO
      IO.Put("*");
    END;
    IO.Put("\n");
  END;
END Stars.


for i in [1..5]
  s = "";
  for j in [1..i]
    s += "*";
  endfor
  player:tell(s);
endfor


! Loops/Continue - simula67 - 07/03/2017;
begin
    integer i;
    for i:=1 step 1 until 10 do begin
        outint(i,5);
        if mod(i,5)=0 then begin
            outimage;
            goto loop
        end;
        outtext(", ");
    loop:
    end
 end


1 to: 10 do: [ :i |
    [ :continue |
        i % 5 = 0 ifTrue: [
            Transcript show: i; cr.
            continue value ].
        Transcript
            show: i;
            show: ', '.
    ] valueWithExit.
]


con
  _clkmode = xtal1 + pll16x
  _clkfreq = 80_000_000

obj
  ser : "FullDuplexSerial.spin"

pub main | i
  ser.start(31, 30, 0, 115200)

  repeat i from 1 to 10
    ser.dec(i)
    if i // 5
      ser.str(string(", "))
      next
    ser.str(string(13,10))

  waitcnt(_clkfreq + cnt)
  ser.stop
  cogstop(0)


--#SET TERMINATOR @

SET SERVEROUTPUT ON @

BEGIN
 DECLARE I SMALLINT DEFAULT 1;

 Loop: WHILE (I <= 10) DO
  CALL DBMS_OUTPUT.PUT(I);
  SET I = I + 1;
  IF (MOD(I - 1, 5) = 0) THEN
   CALL DBMS_OUTPUT.PUT_LINE(' ');
   ITERATE Loop;
  END IF;
  CALL DBMS_OUTPUT.PUT(', ');
 END WHILE Loop;
END @


// Loops/Break. Nigel Galloway: February 21st., 2022
let n=System.Random()
let rec fN g=printf "%d " g; if g <> 10 then fN(n.Next(20))
fN(n.Next(20))


[
    [ 20 random [ . ] [ 10 = [ return ] when ] bi 20 random . t ] loop
] with-return


class ForBreak
{
  public static Void main ()
  {
    while (true)
    {
      a := Int.random(0..19)
      echo (a)
      if (a == 10) break
      echo (Int.random(0..19))
    }
  }
}


include random.fs

: main
  begin  20 random dup . 10 <>
  while  20 random .
  repeat ;

\ use LEAVE to break out of a counted loop
: main
  100 0 do
    i random dup .
    10 = if leave then
    i random .
  loop ;


import morfa.base;

for (i in 0..5)
{
    for (j in 0..i+1)
    {
        print("*");
    }
    println("");
}


FORLOOP
 NEW I,J
 FOR I=1:1:5 DO
 .FOR J=1:1:I DO
 ..WRITE "*"
 .WRITE !
 QUIT


for ($i = 1) ($i <= 5) ($i = $i+1)
    for ($j = 0) ($j < $i) ($j = $j+1)
        print "*"
    end for
    println
end for


forvalues n=1/10 {
	display `n' _continue
	if mod(`n',5)==0 {
		display
		continue
	}
	display ", " _continue
}


ob = Object()
for (i = 1; i <= 10; ++i)
    {
    ob.Add(i)
    if i is 5
        {
        Print(ob.Join(','))
        ob = Object()
        }
    }
Print(ob.Join(','))


for i in 1...10 {
    print(i, terminator: "")
    if i % 5 == 0 {
        print()
        continue
    }
    print(", ", terminator: "")
}


for {set i 1} {$i <= 10} {incr i} {
   puts -nonewline $i
   if {$i % 5 == 0} {
      puts ""
      continue
   }
   puts -nonewline ", "
}


DECLARE @i INT = 0;
DECLARE @str VarChar(40) = '';
WHILE @i<10
  BEGIN
    SET @i = @i + 1;
    SET @str = @str + CONVERT(varchar(2),@i);
    IF @i % 5 = 0
      BEGIN
        PRINT @str;
        SET @str =''
        CONTINUE;
      END
    SET @str = @str +', ';
  END;


$$ MODE TUSCRIPT
numbers=""
LOOP n=1,10
numbers=APPEND (numbers,", ",n)
rest=n%5
IF (rest!=0) CYCLE
 PRINT numbers
 numbers=""
ENDLOOP


program Example
  implicit none

  real :: r
  integer :: a, b

  do
     call random_number(r)
     a = int(r * 20)
     write(*,*) a
     if (a == 10) exit
     call random_number(r)
     b = int(r * 20)
     write(*,*) b
  end do

end program Example


' FB 1.05.0 Win64

Dim i As Integer
Randomize
Do
  i = Int(Rnd * 20)
  Print Using "##"; i;
  Print "  ";
  If i = 10 Then Exit Do
  i = Int(Rnd * 20)
  Print Using "##"; i;
  Print"  ";
Loop

Print
Sleep


include "NSLog.incl"

long num
do
num = rnd(20) - 1
NSLog(@"%ld",num)
until ( num == 10 )

HandleEvents


for (int i = 0; i < 5; i++)
{
    for (int j = 0; j <= i; j++)
    {
        Write("*");
    }
    WriteLine();
}


/* NetRexx */
options replace format comments java crossref savelog symbols nobinary

  say
  say 'Loops/For'

  loop i_ = 1 to 5
    loop for i_
      say '*\-'
      end
    say
    end i_


Z=1
while (( Z<=10 )); do
    echo -e "$Z\c"
    if (( Z % 5 != 0 )); then
        echo -e ", \c"
    else
        echo -e ""
    fi
    (( Z++ ))
done


yes \ | cat -n | head -n 10 | xargs -n 5 echo | tr ' ' ,


decl int i
for (set i 1) (< i 11) (inc i)
        if (= (mod i 5) 0)
                out i endl console
                continue
        end if
        out i ", " console
end for


for (int i = 1; i <= 10; i++) {
  stdout.printf("%d", i);
  if (i % 5 == 0) {
    stdout.printf("\n");
    continue;
  }
  stdout.printf(", ");
}


Public Sub LoopContinue()
    Dim value As Integer
    For value = 1 To 10
        Debug.Print value;
        If value Mod 5 = 0 Then
            'VBA does not have a continue statement
            Debug.Print
        Else
            Debug.Print ",";
        End If
    Next value
End Sub


Public Sub Form_Open()
Dim iRand As Integer

Repeat
  iRand = Rnd * 20
  Print iRand
Until iRand = 10

End


while(1)
    {
    a = floor(random(19))
    show_message(string(a))
    if(a = 10)
        break
    b = floor(random(19))
    show_message(string(a))
    }


package main

import "fmt"
import "math/rand"
import "time"

func main() {
    rand.Seed(time.Now().UnixNano())
    for {
        a := rand.Intn(20)
        fmt.Println(a)
        if a == 10 {
            break
        }
        b := rand.Intn(20)
        fmt.Println(b)
    }
}


for i in 1..5:
  for j in 1..i:
    stdout.write("*")
  echo("")


10 FOR I=1 TO 5
20 FOR J=1 TO I
30 PRINT "*";
40 NEXT
50 PRINT
60 NEXT


MODULE LoopFor;
IMPORT
  Out;
VAR
  i, j: INTEGER;

BEGIN
  FOR i := 1 TO 5 DO
    FOR j := 1 TO i DO
      Out.Char('*');
    END;
    Out.Ln
  END
END LoopFor.


for (#1 = 1; #1 <= 10; #1++) {
    Num_Type(#1, LEFT+NOCR)
    if (#1 % 5 == 0) {
        Type_Newline
        Continue
    }
    Message(", ")
}


fn main() {
    for i in 1..11 {
        print(i)
        if i%5==0{
            println('')
            continue
        }
        print(', ')
    }
}


for (i in 1..10) {
    System.write(i)
    if (i%5 == 0) {
        System.print()
        continue
    }
    System.write(", ")
}

System.print()


extern _printf

section .data
    output db 0,0,0,0
    reversedOutput db 0,0

section .text
global _main
_main:
    mov ecx, 0
    looping:
        inc ecx
        mov eax, ecx
        push ecx
        cmp ecx, 5
        je do5
        cmp ecx, 10
        je do10
    don:
        call createOutput
        mov [eax+1], byte 0x2c
        mov [eax+2], byte 0x20
        push eax
        call _printf
        add esp, 4
        pop ecx
        jmp looping
    do5:
        call createOutput
        mov [eax+1], byte 0x0a
        push eax
        call _printf
        add esp, 4
        pop ecx
        jmp looping
    do10:
        call createOutput
        mov [eax+2], byte 0x0a
        push eax
        call _printf
        add esp, 4
        pop ecx
        xor eax, eax
        ret

createOutput: ;parameter in eax
    ;eax between 1 and 99
    push ebx
    mov ecx, 0
    clearOutput:
        mov [output+ecx], byte 0
        cmp ecx, 3
        je next
        inc ecx
        jmp clearOutput
    next:
        mov ecx, 0
        mov ebx, 10
    cOlooping:
        xor edx, edx
        div ebx
        mov [reversedOutput+ecx], dl
        add [reversedOutput+ecx], byte 0x30
        cmp eax, 0
        je reverse
        cmp ecx, 1
        je reverse
        inc ecx
        jmp cOlooping
    reverse:
        mov ecx, -1
        mov ebx, 0
        name:
            inc ecx
            neg ecx
            mov dl, [reversedOutput+ecx+1]
            neg ecx
            cmp dl, 0
            je name
            mov [output + ebx], dl
            inc ebx
            cmp ecx, 1
            jl name
        mov eax, output
        pop ebx
        ret


final random = new Random()

while (true) {
    def random1 = random.nextInt(20)
    print random1
    if (random1 == 10) break
    print '     '
    println random.nextInt(20)
}


10 NUM = 0
20 WHILE NUM <> 10
30     NUM = INT(RND * 20)
40     PRINT NUM
50 WEND


PROCEDURE Loop()

   LOCAL n

   DO WHILE .T.
      ? n := hb_RandomInt( 0, 19 )
      IF n == 10
         EXIT
      ENDIF
      ? hb_RandomInt( 0, 19 )
   ENDDO

   RETURN


bundle Default {
  class For {
    function : Main(args : String[]) ~ Nil {
      DoFor();
    }

    function : native : DoFor() ~ Nil {
    	for (i := 0; i < 5; i += 1;) {
          for (j := 0; j <= i; j += 1;) {
            "*"->Print();
          };
          ""->PrintLine();
       };
    }
  }
}


for i = 1 to 5 do
  for j = 1 to i do
    print_string "*"
  done;
  print_newline ()
done


PROGRAM "loopcontinue"

DECLARE FUNCTION Entry()

FUNCTION Entry()
  FOR i% = 1 TO 10
    PRINT i%;
    IF i% MOD 5 = 0 THEN
      PRINT
      DO NEXT ' It looks like DO FOR backs to the FOR with the current value of i%
    END IF
    PRINT ", ";
  NEXT i%
END FUNCTION
END PROGRAM


code CrLf=9, IntOut=11, Text=12;
integer N;
for N:= 1 to 10 do
        [IntOut(0, N); if remainder(N/5) \#0\ then Text(0, ", ") else CrLf(0)]


for i = 1 to 10
  print str$(i);
  if mod(i, 5) = 0 then
    print
    continue
  end if
  print ", ";
next
print
end


foreach n in ([1..10]){print(n); if(n%5==0){println(); continue;} print(", ")}
// or foreach n in ([1..10]){print(n,(n%5) and ", " or "\n")}


const std = @import("std");

pub fn main() !void {
    const stdout_wr = std.io.getStdOut().writer();
    var i: i8 = 1;
    while (i <= 10) : (i += 1) {
        try stdout_wr.print("{d}", .{i});
        if (i == 5) {
            try stdout_wr.writeAll("\n");
            continue;
        }
        try stdout_wr.writeAll(", ");
    }
}


import Control.Monad
import System.Random

loopBreak n k = do
  r <- randomRIO (0,n)
  print r
  unless (r==k) $ do
    print =<< randomRIO (0,n)
    loopBreak n k


class Program {
  static public function main():Void {
    while(true) {
      var a = Std.random(20);
      Sys.println(a);
      if (a == 10)
        break;
      var b = Std.random(20);
      Sys.println(b);
    }
  }
}


while true
  let r rand 20
  println r
  if r = 10
    break
  endif
  println rand 20
endwhile


1  DO i = 1, 1E20 ! "forever"
     a = INT( RAN(10, 10) )
     WRITE(name) a
     IF( a == 10) GOTO 10
     b = INT( RAN(10, 10) )
     WRITE(name) b
   ENDDO
10
 END


for i = 0:1:4
  for j = 0:1:i
    printf("*");
  endfor
  printf("\n");
endfor


: loopFor(n)
| i j |
   n loop: i [
      i loop: j [ "*" print ]
      printcr ;


1 1 5 {dup {`*'} repeat bdup bpop ncat `\n' cat print} for flush


U16 a, b;
while (1) {
  a = RandU16 % 20;
  Print("%d\n", a);

  if (a == 10) break;

  b = RandU16 % 20;
  Print("%d\n", b);
}


procedure main()
    while 10 ~= writes(?20-1) do write(", ",?20-1)
end


loop(
    a := Random value(0,20) floor
    write(a)
    if( a == 10, writeln ; break)
    b := Random value(0,20) floor
    writeln(" ",b)
)


loopexample=: verb define
  while. 1 do.
    smoutput n=. ?20
    if. 10=n do. return. end.
    smoutput ?20
  end.
)


#include <order/interpreter.h>

ORDER_PP(
  8for_each_in_range(8fn(8I,
                         8print(
                           8for_each_in_range(8fn(8J, 8print((*))),
                                              1, 8plus(8I, 1))
                           8space)),
                         1, 6)
)


for I in 1..5 do
   for _ in 1..I do
      {System.printInfo "*"}
   end
   {System.showInfo ""}
end


dim x,y

for x=1 to 5

    for y=1 to x

    print "*";

    next y

print

next x


import java.util.Random;

Random rand = new Random();
while(true){
    int a = rand.nextInt(20);
    System.out.println(a);
    if(a == 10) break;
    int b = rand.nextInt(20);
    System.out.println(b);
}


for (;;) {
  var a = Math.floor(Math.random() * 20);
  print(a);
  if (a == 10)
    break;
  a = Math.floor(Math.random() * 20);
  print(a);
}


program stars(output);

var
  i, j: integer;

begin
  for i := 1 to 5 do
    begin
      for j := 1 to i do
        write('*');
      writeln
    end
end.


for i=1 to 5 do
    for j=1 to i do
        puts(1,"*")
    end for
    puts(1,"\n")
end for


while true
    n = rand(0:19)
    @printf "%4d" n
    if n == 10
        println()
        break
    end
    n = rand(0:19)
    @printf "%4d\n" n
end


import java.util.Random

fun main(args: Array<String>) {
    val rand = Random()
    while (true) {
        val a = rand.nextInt(20)
        println(a)
        if (a == 10) break
        println(rand.nextInt(20))
    }
}


{def loops_break
 {lambda {:n}
  {if {= :n 10}
   then :n -> end of loop
   else :n {loops_break {round {* 20 {random}}}}}}}
-> loops_break

{loops_break 0}
-> 0 16 8 5 9 17 9 18 1 18 1 1 12 13 15 1 10 -> end of loop


go =>
  N = 5,
  foreach(I in 1..N)
    foreach(_J in 1..I)
      print("*")
    end,
    nl
  end.


(for N 5
   (do N (prin "*"))
   (prinl) )


do 20 ? int dup . 10 == if break then 20 ? int . loop


for {
    val .i = random 0..19
    write .i, " "
    if .i == 10 { writeln(); break }
    write random(0..19), " "
}


local(x = 0)
while(#x != 10) => {^
	#x = integer_random(19,0)
	#x
	#x == 10 ? loop_abort
	', '+integer_random(19,0)+'\r'
^}


while num<>10
    num=rnd(1)*20
    print num
    if num=10 then exit while
    print rnd(1)*20
wend


repeat while TRUE
  n = random(20)-1
  put n
  if n = 10 then exit repeat
  put random(20)-1
end repeat


C  :i = 1
*OuterLoop
C  :j = 0
C  :$stars =
*InnerLoop
C  :j = j + 1
C  :$stars =*$stars
J ( j < i )          :*InnerLoop
T  :$stars
C  :i = i + 1
J ( i < 6 )          :*OuterLoop
END:


do i = 1 to 5;
   do j = 1 to i;
      put edit ('*') (a);
   end;
   put skip;
end;


To run:
Start up.
Write a triangle of asterisks on the console given 5.
Wait for the escape key.
Shut down.

To write a row of asterisks on the console given a number:
If a counter is past the number, write "" on the console; exit.
Write "*" on the console without advancing.
Repeat.

To write a triangle of asterisks on the console given a size:
If a counter is past the size, exit.
Write a row of asterisks on the console given the counter.
Repeat.


Section Header

+ name := TEST_LOOP_BREAK;

Section Public

- main <- (
  + a, b : INTEGER;

  `srand(time(NULL))`;
  {
    a := `rand()`:INTEGER % 20; // not exactly uniformly distributed, but doesn't matter
    a.print;
    '\n'.print;
    a == 10
  }.until_do {
    b := `rand()`:INTEGER % 20; // not exactly uniformly distributed, but doesn't matter
    b.print;
    '\n'.print;
  }
);


command loopForeverRandom
    repeat forever
        put random(20) - 1 into tRand
        put tRand
        if tRand is 10 then exit repeat
        put random(20) - 1
    end repeat
end loopForeverRandom


repeat
  k = math.random(19)
  print(k)
  if k == 10 then break end
  print(math.random(19)
until false


Module Checkit {
      M=Random(0, 19)
      Print M
      If M=10 then Continue  ' because loop flag is false, continue act as Exit
      Print Random(0, 19)
      loop
}
Checkit

Module Checkit {
      do {
            do {
                  {
                        M=Random(0, 19)
                        Print M
                        If M=10 then Break
                        Print Random(0, 19)
                        loop
                  }
                  Print "no print this"
            } always
            Print "no print this"
      } always
      Print "print ok"
}
Checkit


define(`randSeed',141592653)dnl
define(`setRand',
   `define(`randSeed',ifelse(eval($1<10000),1,`eval(20000-$1)',`$1'))')dnl
define(`rand_t',`eval(randSeed^(randSeed>>13))')dnl
define(`random',
   `define(`randSeed',eval((rand_t^(rand_t<<18))&0x7fffffff))randSeed')dnl
dnl
define(`loopbreak',`define(`a',eval(random%20))`a='a
ifelse(a,10,`',`define(`b',eval(random%20))`b='b
loopbreak')')dnl
dnl
loopbreak


lvars i, j;
for i from 1 to 5 do
    for j from 1 to i do
        printf('*','%p');
    endfor;
    printf('\n')
endfor;


for ($i = 1; $i -le 5; $i++) {
    for ($j = 1; $j -le $i; $j++) {
        Write-Host -NoNewline *
    }
    Write-Host
}


r := rand( 0 .. 19 ):
do
        n := r();
        printf( "%d\n", n );
        if n = 10 then
                break
        end if;
        printf( "%d\n", r() );
end do:


While[(Print[#];#!=10)&[RandomIntger[{0,19}]],
         Print[RandomInteger[{0,19}]
        ]


/* To exit the innermost block, use return(<value>) */

block([n],
   do (
      n: random(20),
      ldisp(n),
      if n = 10 then return(),
      n: random(20),
      ldisp(n)
   )
)$

/* To exit any level of block, use catch(...) and throw(<value>);
they are not used for catching exceptions, but for non-local
return. Use errcatch(...) for exceptions. */

block([n],
   catch(
      do (
         n: random(20),
         ldisp(n),
         if n = 10 then throw('done),
         n: random(20),
         ldisp(n)
      )
   )
)$

/* There is also break(<value>, ...) in Maxima. It makes Maxima
stop the evaluation and enter a read-eval loop where one can change
variable values, then return to the function after exit; For example */

block([x: 1], break(), ldisp(x));
> x: 2;
> exit;
2


while true do
(
	a = random 0 19
	format ("A: % \n") a
	if a == 10 do exit
	b = random 0 19
	format ("B: % \n") b
)


randomize
(19 random puts 10 ==) (19 random puts!) () () linrec


example :-
    between(1,5,I), nl, between(1,I,_J),
    write('*'), fail.
example.


import sys
for i in xrange(5):
    for j in xrange(i+1):
        sys.stdout.write("*")
    print


FOR c = 1 TO 5
    FOR n = 1 TO c
        PRINT "*";
    NEXT
    PRINT
NEXT


MODULE Break EXPORTS Main;

IMPORT IO, Fmt, Random;

VAR a,b: INTEGER;

BEGIN
  WITH rand = NEW(Random.Default).init() DO
    LOOP
      a := rand.integer(min := 0, max := 19);
      IO.Put(Fmt.Int(a) & "\n");
      IF a = 10 THEN EXIT END;
      b := rand.integer(min := 0, max := 19);
      IO.Put(Fmt.Int(b) & "\n");
    END;
  END;
END Break.


while (1)
  a = random(20) - 1;
  player:tell(a);
  if (a == 10)
    break;
  endif
  b = random(20) - 1;
  player:tell(b);
endwhile


BREAKLOOP
 NEW A,B
 SET A=""
 FOR  Q:A=10  DO
 .SET A=$RANDOM(20)
 .WRITE !,A
 .Q:A=10
 .SET B=$RANDOM(20)
 .WRITE ?6,B
 KILL A,B
 QUIT
 ;A denser version that doesn't require two tests
 NEW A,B
 FOR  SET A=$RANDOM(20) WRITE !,A QUIT:A=10  SET B=$RANDOM(20) WRITE ?6,B
 KILL A,B QUIT


(for ([i (in-range 1 6)]) (for ([j i]) (display "*")) (newline))


/**
 Loops/Break in Neko
 Tectonics:
   nekoc loops-break.neko
   neko loops-break
*/

var random_new = $loader.loadprim("[email protected]_new", 0);
var random_int = $loader.loadprim("[email protected]_int", 2);

var random = random_new();

while true {
  var r = random_int(random, 20);
  $print(r, " ");

  if r == 10 break;

  r = random_int(random, 20);
  $print(r, " ");
}
$print("\n");


using System;
using System.Console;
using Nemerle.Imperative;

module Break
{
    Main() : void
    {
        def rnd = Random();
        while (true)
        {
            def a = rnd.Next(20);
            WriteLine(a);
            when (a == 10) break;
            def b = rnd.Next(20);
            WriteLine(b);
        }
    }
}


/* NetRexx */
options replace format comments java crossref savelog symbols nobinary

  say
  say 'Loops/Break'
  rn = Rexx
  rnd = Random()

  loop label lb forever
    rn = rnd.nextInt(19)
    say rn.right(3)'\-'
    if rn = 10 then leave lb
    rn = rnd.nextInt(19)
    say rn.right(3)'\-'
    end lb
  say


(until (= 10 (println (rand 20)))
  (println (rand 20)))


; Use 'repeat' when an index required, 'loop' when repetition suffices:

repeat i 5 [
	loop i [prin "*"]
	print ""
]

; or a more traditional for loop:

for i 1 5 1 [
	loop i [prin "*"]
	print ""
]


Red[]

repeat i 5 [
    loop i [prin "*"]
    prin newline
]


let s = ref("")
for i in 1 to 5 {
  for _ in 1 to i {
    s := Js.String2.concat(s.contents, "*")
  }
  s := Js.String2.concat(s.contents, "\n")
}
Js.log(s.contents)


import random

while true:
  let a = random(19)
  echo a
  if a == 10:
    break
  let b = random(19)
  echo b


10 I=RND(20)
20 PRINT I
30 IF I=10 THEN STOP
40 PRINT RND(20)
50 GOTO 10


MODULE LoopBreak;
IMPORT
  RandomNumbers,
  Out;

PROCEDURE Do();
VAR
  rn: LONGINT;
BEGIN
  LOOP
    rn := RandomNumbers.RND(20);
    Out.LongInt(rn,0);Out.Ln;
    IF rn = 10 THEN EXIT END;
    rn := RandomNumbers.RND(20);
    Out.LongInt(rn,0);Out.Ln
  END
END Do;

BEGIN
  Do
END LoopBreak.


while(true) {
  a := (Float->Random() * 20.0)->As(Int);
  a->PrintLine();
  if(a = 10) {
    break;
  };
  a := (Float->Random() * 20.0)->As(Int);
  a->PrintLine();
}


/*REXX program demonstrates an outer DO loop controlling the inner DO loop with a "FOR".*/

       do j=1  for 5                             /*this is the same as:   do j=1  to 5  */
       $=                                        /*initialize the value to a null string*/
              do k=1  for j                      /*only loop for a   J   number of times*/
              $= $ || '*'                        /*using concatenation  (||)  for build.*/
              end   /*k*/
       say $                                     /*display character string being built.*/
       end          /*j*/                        /*stick a fork in it,  we're all done. */


for i = 1 to 5 for x = 1 to i see "*" next see nl next


fn main() {
    for i in 0..5 {
        for _ in 0..=i {
            print!("*");
        }

        println!();
    }
}


# Random.self_init();;
- : unit = ()

# while true do
    let a = Random.int 20 in
    print_int a;
    print_newline();
    if a = 10 then raise Exit;
    let b = Random.int 20 in
    print_int b;
    print_newline()
  done;;
15
18
2
13
10
Exception: Pervasives.Exit.


while(1)
  a = floor(unifrnd(0,20, 1));
  disp(a)
  if ( a == 10 )
    break
  endif
  b = floor(unifrnd(0,20, 1));
  disp(b)
endwhile


while(true) [
      19 rand dup print ":" print
      10 == ifTrue: [ break ]
      19 rand print " " print
   ]


data _null_;
length a $5;
do n=1 to 5;
  a="*";
  do i=2 to n;
    a=trim(a) !! "*";
  end;
  put a;
end;
run;

/* Possible without the inner loop. Notice TRIM is replaced with STRIP,
otherwise there is a blank space on the left */

data _null_;
length a $5;
do n=1 to 5;
  a=strip(a) !! "*";
  put a;
end;
run;


class MAIN is
  -- from, to, step
  for!(once init:INT, once to:INT, once inc:INT):INT is
    i ::= init;
    loop while!( i <= to );
      yield i;
      i := i + inc;
    end;
  end;

  main is
    i, j :INT;
    loop i := for!(1, 5, 1);   -- 1.upto!(5)
      loop j := for!(1, i, 1); -- 1.upto!(i)
        #OUT + "*";
      end;
      #OUT + "\n";
    end;
  end;
end;


for (i <- 1 to 5) {
    for (j <- 1 to i)
        print("*")
    println()
}


(import (otus random!))

(call/cc (lambda (break)
   (let loop ()
      (if (= (rand! 20) 10)
         (break #t))
      (print (rand! 20))
      (loop))))


/*REXX ****************************************************************
* Three Ways to leave a Loop
* ooRexx added the possibility to leave an outer loop
* without using a control variable
* 12.05.2013 Walter Pachl
**********************************************************************/
do i1=1 To 2                           /* an outer loop              */
  Say 'i1='i1                          /* tell where we are          */
  Call random ,,123                    /* seed to be reproducable    */
  do forever                           /* inner loop                 */
    a=random(19)
    Say a
    if a=6  then leave                 /* leaces the innermost loop  */
    end
  end

do i2=1 To 2
  Say 'i2='i2
  Call random ,,123
  do forever
    a=random(19)
    Say a
    if a=6  then leave i2    /* leaves loop with control variable i2 */
    end
  end

Parse Version v
Select
  When pos('ooRexx',v)>0 Then supported=1
  Otherwise                   supported=0
  End
If supported Then Do
  Say 'Leave label-name is supported in' v
do Label i3 Forever
  Say 'outer loop'
  Call random ,,123
  do forever
    a=random(19)
    Say a
    if a=6  then leave i3          /* leaves loop with label name i3 */
    end
  end
End
Else
  Say 'Leave label-name is probably not supported in' v


for break:Break do
   R = {OS.rand} mod 20
in
   {Show R}
   if R == 10 then {Break}
   else {Show {OS.rand} mod 20}
   end
end


for i=1:5
    s=""
    for j=1:i
        s=s+"*"
    end
    printf("%s\n",s)
end


for I range 1 to 5 do
  for J range 1 to I do
    write("*");
  end for;
  writeln;
end for;


for i in {1..5} loop
    for j in {1..i} loop
        nprint( '*' );
    end loop;
    print;    -- new line
end loop;


while(1,
  t=random(20);
  print(t);
  if(t==10, break);
  print(random(20))
)


while (1) {
    my $a = int(rand(20));
    print "$a\n";
    if ($a == 10) {
        last;
    }
    my $b = int(rand(20));
    print "$b\n";
}


begin
   integer i,j;
   for i:=1 step 1 until 5 do
   begin
      for j:=1 step 1 until i do
         outtext("*");
      outimage
   end
end


1 to: 5 do: [| :n | inform: ($* repeatedTimes: n)].


1 to: 5 do: [ :aNumber |
  aNumber timesRepeat: [ '*' display ].
  Character nl display.
]


integer i
while 1 do
    i = rand(20)-1
    printf(1, "%g ", {i})
    if i=10 then exit end if
    printf(1, "%g\n", {rand(20)-1})
end while


(use R
   (loop
      (println (setq R (rand 1 19)))
      (T (= 10 R))
      (println (rand 1 19)) ) )


int main(){
   while(1){
      int a = random(20);
      write(a + "\n");
      if(a == 10){
         break;
      }
      int b = random(20);
      write(b + "\n");
   }
}


ol	outer = ?lt(outer,5) outer + 1	:f(end)
	inner = outer; stars = ""
il	stars = ?gt(inner,0) stars "*"	:f(disp)
	inner = inner - 1	:(il)
disp	output = stars;	:(ol)
end


for (var row = 1; row <= 5; row++) {
    for (var col = 1; col <= row; col++) {
        printf("*");
    }

    print();
}


con
  _clkmode = xtal1 + pll16x
  _clkfreq = 80_000_000

obj
  ser : "FullDuplexSerial.spin"

pub main | m, n
  ser.start(31, 30, 0, 115200)

  repeat n from 1 to 5
    repeat m from 1 to n
      ser.tx("*")
    ser.str(string(13,10))

  waitcnt(_clkfreq + cnt)
  ser.stop
  cogstop(0)


do forever;
   k = trunc(random()*20);
   put (k);
   if k = 10 then leave;
   k = trunc(random()*20);
   put skip list (k);
end;


To run:
Start up.
Demonstrate breaking.
Wait for the escape key.
Shut down.

To demonstrate breaking:
Pick a number between 0 and 19.
Write the number to the console.
If the number is 10, break.
Pick another number between 0 and 19.
Write the other number to the console.
Repeat.

To write a number to the console:
Convert the number to a string.
Write the string to the console.


realtime srand          % init RNG
{
    rand 20 mod         % generate number between 0 and 19
    dup =               % print it
    10 eq { exit } if   % exit if 10
} loop


$r = New-Object Random
for () {
    $n = $r.Next(20)
    Write-Host $n
    if ($n -eq 10) {
        break
    }
    Write-Host $r.Next(20)
}


If OpenConsole()

  Repeat
    a = Random(19)
    PrintN(Str(a))
    If a = 10
      Break
    EndIf
    b = Random(19)
    PrintN(Str(b))
    PrintN("")
  ForEver

  Print(#CRLF$ + #CRLF$ + "Press ENTER to exit")
  Input()
  CloseConsole()
EndIf


forvalues n=1/5 {
	local s ""
	forvalues i=1/`n' {
		local s `s'*
	}
	display "`s'"
}


for i in 1...5 {
    for _ in 1...i {
        print("*", terminator: "")
    }
    print()
}


from random import randrange

while True:
    a = randrange(20)
    print(a)
    if a == 10:
        break
    b = randrange(20)
    print(b)


RANDOMIZE TIMER
DO
    n = INT(RND * 20)
    PRINT n,
    IF n = 10 THEN
        EXIT DO
    ELSE
        n = INT(RND * 20)
        PRINT n
    END IF
LOOP UNTIL 0


(define loop -> (if (= 10 (PRINT (random 20)))
                    true
                    (do (PRINT (random 20))
                        (loop))))
(loop)


[ 20 random
  dup echo sp
  10 = if done
  20 random echo cr
  again ]


for {set lines 1} {$lines <= 5} {incr lines} {
    for {set i 1} {$i <= $lines} {incr i} {
        puts -nonewline "*"
    }
    puts ""
}


ClrHome
For(I,1,5
For(J,1,I
Output(I,J,"*
End
End


Local i,j
ClrIO
For i, 1, 5
  For j, 1, i
    Output i*8, j*6, "*"
  EndFor
EndFor


sample0to19 <- function() sample(0L:19L, 1,replace=TRUE)
repeat
{
  result1 <- sample0to19()
  if (result1 == 10L)
  {
    print(result1)
    break
  }
  result2 <- sample0to19()
  cat(result1, result2, "\n")
}


#lang racket
(let loop ()
  (let/ec break
    (define a (random 20))
    (displayln a)
    (when (= a 10) (break))
    (displayln (random 20))
    (loop)))


loop {
    say my $n = (0..19).pick;
    last if $n == 10;
    say (0..19).pick;
}


rebol [
	Title: "Loop/Break"
	URL: http://rosettacode.org/wiki/Loop/Break
]

random/seed 1 ; Make repeatable.
; random/seed now ; Uncomment for 'true' randomness.

r20: does [(random 20) - 1]

forever [
	prin x: r20
	if 10 = x [break]
	print rejoin [" " r20]
]
print ""


Red [
    Title: "Loops/Break"
    URL: http://rosettacode.org/wiki/Loops/Break
]

random/seed 2 ; Make repeatable. Delete line for 'true' randomness.

r20: does [(random 20) - 1]

forever [
    prin x: r20
    if 10 = x [break]
    print rejoin [" " r20]
]
print ""


for(%i = 0; %i < 5; %i++)
{
    for(%x = %i; %x < 5; %x++)
    {
        %string = %string @ "*";
        echo(%string);
    }
}


: PRINTSTARS ( ROWS -- )
1 + 1 DO
I 0 DO
PRINT " * " LOOP
CR LOOP ;
5 PRINTSTARS


$$ MODE TUSCRIPT
m=""
LOOP n=1,5
 m=APPEND (m,"","*")
 PRINT m
ENDLOOP


for (let i: number = 0; i < 5; ++i) {
    let line: string = ""
    for(let j: number = 0; j <= i; ++j) {
        line += "*"
    }
    console.log(line)
}


doc{
A couple of helper functions to make the rest of the
code more readable.
}doc

: rand  ( -n )  random 20 mod ;
: .  ( n- )  putn space ;

doc{
One approach is to use a simple repeat/again loop, and
a conditional exit. For instance:
}doc

: foo   ( - )
  repeat rand dup . 10 = if; rand . again ;

doc{
The other approach uses a structured while loop with the
second printing handled by a conditional clause.
}doc

[ rand dup . 10 <> [ [ rand . ] ifTrue ] sip ] while


/*REXX program demonstrates a    FOREVER   DO  loop  with a test to    LEAVE   (break). */
                                                 /*REXX's RANDOM BIF returns an integer.*/
    do forever                                   /*perform loop until da cows come home.*/
    a=random(19)                                 /*same as:    random(0, 19)            */
    call charout , right(a, 5)                   /*show   A   right─justified, column 1.*/
    if a==10  then leave                         /*is random #=10?  Then cows came home.*/
    b=random(19)                                 /*same as:    random(0, 19)            */
    say right(b, 5)                              /*show   B   right─justified, column 2.*/
    end   /*forever*/                            /* [↑]  CHAROUT , xxx   writes to term.*/
                                                 /*stick a fork in it,  we're all done. */


while true
      a = random(20)
      see a + nl
      if a = 10 exit ok
end


loop do
  a = rand(20)
  print a
  if a == 10
    puts
    break
  end
  b = rand(20)
  puts "\t#{b}"
end


#!/bin/sh
# Using a while control construct to emulate a for loop

l="1"                   # Set the counters to one
while [ "$l" -le 5 ]    # Loop while the counter is less than five
  do
  m="1"
  while [ "$m" -le "$l" ]  # Loop while the counter is less than five
    do
    printf "*"
    m=`expr "$m" + 1`   # Increment the inner counter
  done
  echo
  l=`expr "$l" + 1`   # Increment the outer counter
done


yes \ | cat -n | (while read n ; do
  [ $n -gt 5 ] && exit 0;
  yes \* | head -n $n | xargs -n $n echo
done)


#
# for loop
#

decl int i j
for (set i 0) (< i 5) (inc i)
        for (set j 0) (< j (int (+ i 1))) (inc j)
                out "*" console
        end for
        out endl console
end for


// cargo-deps: rand

extern crate rand;
use rand::{thread_rng, Rng};

fn main() {
    let mut rng = thread_rng();
    loop {
        let num = rng.gen_range(0, 20);
        if num == 10 {
            println!("{}", num);
            break;
        }
        println!("{}", rng.gen_range(0, 20));
    }
}


data _null_;
do while(1);
   n=floor(uniform(0)*20);
   put n;
   if n=10 then leave;    /* 'leave' to break a loop */
end;
run;


-- help class for random number sequence
class RANDOM is
  attr seed:INT;

  create(seed:INT):SAME is
    res:RANDOM := new;
    res.seed := seed;
    return res;
  end;
  -- this code is taken from rand's man (C)
  next:INT is
    seed := seed * 1103515245 + 12345;
    return (seed/65536) % 32768;
  end;
end;

class MAIN is
  main is
    a, b :INT;
    rnd:RANDOM := #(1);
    loop
      a := rnd.next % 20;
      #OUT + a + "\n";
      if a = 10 then break!; end; -- here we break
      b := rnd.next % 20;
      #OUT + b + "\n";
    end;
  end;
end;


scala> import util.control.Breaks.{breakable, break}
import util.control.Breaks.{breakable, break}

scala> import util.Random
import util.Random

scala> breakable {
     |   while(true) {
     |     val a = Random.nextInt(20)
     |     println(a)
     |     if(a == 10)
     |       break
     |     val b = Random.nextInt(20)
     |     println(b)
     |   }
     | }
5
4
10


int main (string[] args) {
    for (var i = 1; i <= 5; i++) {
        for (var j = 1; j <= i; j++) {
	    stdout.putc ('*');
        }
        stdout.putc ('\n');
    }
    return 0;
}


Option Explicit
Sub LoopEx()
    Dim i As Long, j As Long, s As String
    For i = 1 To 5
        s = ""
        For j = 1 To i
            s = s + "*"
        Next
        Debug.Print s
    Next
End Sub


Option Explicit
Dim i, j, s
For i = 1 To 5
    s = ""
    For j = 1 To i
        s = s + "*"
    Next
    WScript.Echo s
Next


(let loop ((first (random 20)))
  (print first)
  (if (not (= first 10))
      (begin
        (print (random 20))
        (loop (random 20)))))


while %T
    a=int(rand()*20)  // [0..19]
    printf("%2d ",a)
    if a==10 then break; end
    b=int(rand()*20)
    printf("%2d\n",b)
end
printf("\n")


$ include "seed7_05.s7i";

const proc: main is func
  local
    var integer: number is 0;
  begin
    repeat
      number := rand(0, 19);
      writeln(number);
      if number <> 10 then
        writeln(rand(0, 19));
      end if;
    until number = 10;
  end func;


var lim = 20;
loop {
    say (var n = lim.rand.int);
    n == 10 && break;
    say lim.rand.int;
}


! Loops/Break - simula67 - 08/03/2017;
begin
  integer num,seed;
  seed:=0;
  while true do
  begin
    num:=randint(1,20,seed);
    outint(num,2); outimage;
    if num=10 then goto lab;
  end;
lab:
end


module main;
  integer  i, j;

  initial begin

    for(i = 1; i <= 5; i = i + 1) begin
    	for(j = 1; j <= i; j = j + 1) $write("*");
    	$display("");
    end
  $finish ;
  end
endmodule


fn main() {
    for i in 1..6 {
        for _ in 1..i+1 {
            print("*")
        }
        print("\n")
    }
}


[
    |first second done|

    first := Random nextIntegerBetween:0 and:19.
    Stdout print:first; cr.
    (done := (first == 10)) ifFalse:[
        second := Random nextIntegerBetween:0 and:19.
        Stdout print:' '; print:second; cr.
    ].
    done
] whileFalse


let: rnd 19 random;

@rnd {
  $ str say
  10 = &break when
  @rnd pop str say
} for


	input(.random,io_findunit(),1,"/dev/urandom")
while	&ALPHABET random @rand
	output = rand = rand - (rand / 20) * 20
	eq(rand,10)	 :f(while)
end


con
  _clkmode = xtal1 + pll16x
  _clkfreq = 80_000_000

obj
  ser : "FullDuplexSerial.spin"

pub main | r, s
  ser.start(31, 30, 0, 115200)

  s := 1337 ' PRNG seed

  repeat
    r := ||?s // 20
    ser.dec(r)
    ser.tx(32)
    if r == 10
      quit
    r := ||?s // 20
    ser.dec(r)
    ser.tx(32)

  waitcnt(_clkfreq + cnt)
  ser.stop
  cogstop(0)


for y=0 to 4
print 1 ""
for x=0 to y
print 1 at x,y "*"
next
next
end


for (i in 1..5) {
    for (j in 1..i) System.write("*")
    System.print()
}


loops:      mov       bx,      1    ; outer loop counter

outerloop:  mov       cx,      bx   ; inner loop counter
            mov       dl,      42   ; '*' character

innerloop:  mov       ah,      6
            int       21h           ; print

            dec       cx
            jcxz      innerdone
            jmp       innerloop

innerdone:  mov       dl,      10   ; newline
            mov       ah,      6
            int       21h

            inc       bx
            cmp       bx,      6
            jne       outerloop

            ret


--#SET TERMINATOR @

SET SERVEROUTPUT ON@

BEGIN
 DECLARE VAL INTEGER;
 LOOP: WHILE (TRUE = TRUE) DO
  SET VAL = INTEGER(RAND() * 20);
  CALL DBMS_OUTPUT.PUT_LINE(VAL);
  IF (VAL = 10) THEN
   LEAVE LOOP;
  END IF;
  SET VAL = INTEGER(RAND() * 20);
  CALL DBMS_OUTPUT.PUT_LINE(VAL);
 END WHILE LOOP;
END @


while 1 {
	local n=runiformint(0,19)
	display `n'
	if `n'==10 continue, break
	display runiformint(0,19)
}


forever
    {
    Print(i = Random(20))
    if i is 10
        break
    Print(i = Random(20))
    }


while true
{
  let a = Int(arc4random()) % (20)
  print("a: \(a)",terminator: "   ")
  if (a == 10)
  {
    break
  }
  let b = Int(arc4random()) % (20)
  print("b: \(b)")
}


while true {
    set a [expr int(20*rand())]
    puts $a
    if {$a == 10} {
        break
    }
    set b [expr int(20*rand())]
    puts $b
}


PROGRAM "for"

DECLARE FUNCTION Entry()

FUNCTION Entry()
  FOR i% = 1 TO 5
    FOR j% = 1 TO i%
      PRINT "*";
    NEXT j%
    PRINT
  NEXT i%
END FUNCTION
END PROGRAM


const repChar:string = "*";
const maxIters = 5;
for(i=1;maxIters;1){
	set str:string = "";
	for(o=1;i;1){
		str+=repChar;
	}
	log(str);
}


code ChOut=8, CrLf=9;
int I, J;
for I:= 1 to 5 do
    [for J:= 1 to I do
        ChOut(0, ^*);
    CrLf(0);
    ]


Local x
Loop
  rand(20)-1 → x
  Disp x                     © new line and text
  If x = 10 Then
    Exit
  EndIf
  Output 64, 50, rand(20)-1  © paint text to the right on same line
EndLoop


for(%a = 0; %a > -1; %a++)
{
    %number = getRandom(0, 19);
    if(%number == 10)
        break;
}


DECLARE @i INT;
WHILE 1=1
BEGIN
    SET @i = ABS(CHECKSUM(NewId())) % 20;
    PRINT @i;
    IF @i=10 BREAK;
    PRINT ABS(CHECKSUM(NewId())) % 20;
END;


$$ MODE TUSCRIPT
LOOP
a=RANDOM_NUMBERS (0,19,1)
IF (10==a) THEN
 PRINT "a=",a
 STOP
ELSE
 b=RANDOM_NUMBERS (0,19,1)
 PRINT "a=",a," b=",b
ENDIF
IF (10==a,b) STOP
ENDLOOP


Do
  n = RND(20)
  Print n
  Until n = 10
  Print RND(20)
Loop


while true; do
	a=`jot -w %d -r 1 0 20` || exit $?
	echo $a
	test 10 -eq $a && break
	b=`jot -w %d -r 1 0 20` || exit $?
	echo $b
done


org &4000		; put code at memory address 0x4000
wr_char equ &bb5a ; write ASCII character in register A to screen
				; (jumps into CPC ROM)

; put registers on stack so we can return to BASIC later
push bc
push de
push hl

ld b,5		; loop from 5 to 1

row:

push bc	; save outer loop variable

; calculate inner loop limit (6 - outer loop variable)
ld a,6
sub b
ld b,a

column:

ld a,42	; asterisk in ASCII
call wr_char
djnz column ; decrement B, jump to label if non-zero

pop bc	; restore outer loop

; print carriage return/line feed
ld a,13
call wr_char
ld a,10
call wr_char

djnz row

; restore registers
pop hl
pop de
pop bc
ret	; return to BASIC interpreter


foreach i in ([1..5]){
   foreach j in (i){print("*")}
   println();
}


const std = @import("std");

pub fn main() !void {
    const stdout_wr = std.io.getStdOut().writer();
    var i: u8 = 1;
    while (i < 5) : (i += 1) {
        var j: u8 = 1;
        while (j <= i) : (j += 1)
            try stdout_wr.writeAll("*");
        try stdout_wr.writeAll("\n");
    }
}


decl ursa.util.random r
decl int a b
while true
        set a (r.getint 19)
        out a endl console
        if (= a 10)
                break
        end while
        set b (r.getint 19)
        out b endl console
end while


Public Sub LoopsBreak()
    Dim value As Integer
    Randomize
    Do While True
        value = Int(20 * Rnd)
        Debug.Print value
        If value = 10 Then Exit Do
        Debug.Print Int(20 * Rnd)
    Loop
End Sub


Dim a, b, i

Do
    a = Int(Rnd * 20)
    WScript.StdOut.Write a
    If a = 10 Then Exit Do
    b = Int(Rnd * 20)
    WScript.Echo vbNullString, b
Loop

For i = 1 To 100000
    a = Int(Rnd * 20)
    WScript.StdOut.Write a
    If a = 10 Then Exit For
    b = Int(Rnd * 20)
    WScript.Echo vbNullString, b
Next


Module Program
    Sub Main()
        ' Initialize with seed 0 to get deterministic output (may vary across .NET versions, though).
        Dim rand As New Random(0)

        Do
            Dim first = rand.Next(20) ' Upper bound is exclusive.
            Console.Write(first & " ")

            If first = 10 Then Exit Do

            Dim second = rand.Next(20)
            Console.Write(second & " ")
        Loop
    End Sub
End Module


import rand
import rand.seed

fn main() {
    rand.seed(seed.time_seed_array(2))
    for {
        a := rand.intn(20)?
        println(a)
        if a == 10 {
            break
        }
        b := rand.intn(20)?
        println(b)
    }
}


import "random" for Random

var r = Random.new()
while (true) {
    var n = r.int(20)
    System.print(n)
    if (n == 10) break
    System.print(r.int(20))
}


PROGRAM "loopbreak"

IMPORT "xst" ' for XstGetSystemTime

DECLARE FUNCTION Entry()

' Pseudo-random number generator
' Based on the rand, srand functions from Kernighan & Ritchie's book
' 'The C Programming Language'
DECLARE FUNCTION Rand()
DECLARE FUNCTION SRand(seed%%)

FUNCTION Entry()
  XstGetSystemTime (@msec)
  SRand(INT(msec) MOD 32768)
  DO
    a%% = Rand() MOD 20
    PRINT FORMAT$("##", a%%);
    IF a%% = 10 THEN EXIT DO
    b%% = Rand() MOD 20
    PRINT FORMAT$(" ##", b%%)
  LOOP
  PRINT
END FUNCTION

' Return pseudo-random integer on 0..32767
FUNCTION Rand()
  #next&& = #next&& * 1103515245 + 12345
END FUNCTION USHORT(#next&& / 65536) MOD 32768

' Set seed for Rand()
FUNCTION SRand(seed%%)
  #next&& = seed%%
END FUNCTION

END PROGRAM


while(true){
	set n:number = math.random(0,19);
	log(`first: {n}`);
	if(n==10){stop}
	n = math.random(0,19);
	log(`second: {n}`);
}


include c:\cxpl\codes;
int N;
loop    [N:= Ran(20);
        IntOut(0, N);
        if N=10 then quit;
        ChOut(0, 9\tab\);
        IntOut(0, Ran(20));
        CrLf(0);
        ]


do
	i = int(ran(19))
	print i using "##";
	print "  ";
	if i = 10 then break : fi
	i = int(ran(19))
	print i using "##", "  ";
loop
print
end


const std = @import("std");

pub fn main() !void {
    const RndGen = std.rand.DefaultPrng;
    var rnd = RndGen.init(42);
    // possible improvement: make rng fair
    var rand_num1: u5 = undefined;
    var rand_num2: u5 = undefined;
    while (true) {
        rand_num1 = rnd.random().int(u5) % 20;
        try std.io.getStdOut().writer().print("{d}\n", .{rand_num1});
        if (rand_num1 == 10)
            break;
        rand_num2 = rnd.random().int(u5) % 20;
        try std.io.getStdOut().writer().print("{d}\n", .{rand_num2});
    }
}


while(1){n:=(0).random(20); n.print("  ");
   if (n==10){ println(); break; } (0).random().println();
}


with Ada.Text_IO;

procedure Longest_Strings is
   use Ada.Text_IO;

   -- first, in order to strictly use integer, I use integer in
   -- place of an enumeration type: -1 => not-equal
   --                                0 => shorter - ignore, no print current string
   --                                1 => equal - print current and up-stream
   --                                2 => longer - no print upstream, only current and equal subsequent
   --                           others => null; -- must never happen.
   --
   -- Anything else that is tested or used that is not a string or integer
   -- is not used explicitly by me, but is a standard part of the language
   -- as provided in the standard libraries (like boolean "End_Of_File").

   function Measure_And_Print_N (O : String := ""; -- original/old string
                                 N : String := ""  -- next/new string
                                ) return Integer is
      T1 : String := O;
      T2 : String := N;
      L  : Integer := 1; -- Length defaults to the same;
      function Test_Length (O : in out String; -- original/old string
                            N : in out String) -- new/test-subject string
                            return Integer is
         function Test_Equal (O : in out String; N : in out String)
                              return Integer is
         begin
            O := N;
            return 1;
         exception
            when Constraint_Error =>
               return -1;
         end;
      begin
         case Test_Equal (O, N) is
         when -1 =>
            O (N'Range) := N;
            return 0;
         when 1 =>
            return 1;
         when others =>
            return -1;
         end case;
      exception
         when Constraint_Error =>
            return 2;
      end;
   begin
         case Test_Length (T1, T2) is
         when 0 =>

            -- N < O, so return "shorter"  do not print N

            if End_Of_File
            then
               return 0;
            else
               case Measure_And_Print_N (O, Get_Line) is
                  when 0 =>
                     return 0;
                  when 1 =>
                     return 0;
                  when 2 =>
                     return 2; -- carry up any subsequent canceling of print.
                  when others =>
                     raise Numeric_Error;
               end case;
            end if;
         when 1 =>

            -- O = N, so return "equal"  print N if all subsequent values are
            -- less than or equal to N

            if End_Of_File
            then
               Put_Line (N);
               return 1;
            else
               case Measure_And_Print_N (O, Get_Line) is
                  when 0 =>
                     Put_Line (N);
                     return 1;
                  when 1 =>
                     Put_Line (N);
                     return 1;
                  when 2 =>  -- carry up the subsequent canceling of print.
                     null;
                     return 2;
                  when others =>
                     raise Numeric_Error;
               end case;
            end if;
         when 2 =>

            -- N > O, so return "longer" to cancel printing all previous values
            -- and print N if it is also equal to or greater than descendant
            -- values.

            if End_Of_File
            then
               Put_Line (N);
               return 2;
            else
               case Measure_And_Print_N (N, Get_Line) is
                  when 0 =>
                     Put_Line (N);
                     return 2;
                  when 1 =>
                     Put_Line (N);
                     return 2;
                  when 2 =>  -- printing N cancelled by subsequent input.
                     null;
                     return 2;
                  when others =>
                     raise Numeric_Error;
               end case;
            end if;
         when others =>

            -- This should never happen - raise exception

            raise Numeric_Error;
         end case;
   end;
begin
   if End_Of_File
   then
      null;
   else
      case Measure_And_Print_N ("", Get_Line) is
         when 0 =>
            Put_Line (Current_Error,
                      "Error, Somehow the input line is calculated as less than zero!");
         when 1 =>
            Put_Line (Current_Error,
                      "All input lines appear to be blank.");
         when 2 =>
            null;
         when others =>
            raise Numeric_Error;
      end case;
   end if;
end;


BEGIN
   INT bound = 1000000;			 CO Arbitrary upper limit on string lengths CO
   INT max;				 CO Length of longest string CO
   INT len;				 CO Length of string under examination CO
   STRING buffer := "";			 CO All characters read from stand in CO
   STRING mask := bound * "0";		 CO High water mark of string length seen so far CO
CO Standard boiler plate CO
   on file end (stand in, (REF FILE f) BOOL: (close (f); GOTO finished));
   DO
      STRING line;
      read ((line, newline));
      buffer PLUSAB line + REPR 10;	CO Concatenate string and newline CO
      mask[UPB line] := "1"		CO And set mask where character exists in line CO
   OD;
finished:
   buffer PLUSAB REPR 10;		CO Guarantee there's a zero-length string at the end CO
CO
   Scan backwards through mask looking for highest index used which is equal to the length
   of the longest string with its terminating newline.
CO
   FOR i FROM bound BY -1 TO 1
   DO
      FROM ABS mask[i] TO ABS "0" DO max := i OD	CO Exploit ABS "1" > ABS "0" CO
   OD;
   FROM 1 TO UPB buffer
   DO							CO Null loop if buffer is empty CO
      VOID (char in string (REPR 10, len, buffer));	CO Pedantry and Algol68 Genie extension CO
      FROM max TO len
      DO						CO Null loop if len < max CO
	 FOR i FROM 1 TO max
	 DO
	    printf (($a$, buffer[i]))			CO Print string and newline CO
	 OD
      OD;
      buffer := buffer[len : UPB buffer];		CO Step over string CO
      buffer := buffer[2 : UPB buffer]			CO Step over newline CO
   OD
END


input =
(
a
bb
ccc
ddd
ee
f
ggg
)
longestLen := 0, buffer := ""
Loop Parse, input, `n
{
   top := SubStr(buffer, 1, InStr(buffer, "`n"))
   StringReplace, top, top, `n
   If SubStr(A_LoopField, LongestLen) ; at least as long
      buffer .= A_LoopField "`n"
   If !SubStr(top, StrLen(A_LoopField)) ; longer
      buffer := A_LoopField "`n", LongestLen := StrLen(A_LoopField)
}
MsgBox % buffer


#!/usr/bin/awk -f
BEGIN {
    maxlen = 0;
    lenList = 0;
}

{
   if (length($0)>maxlen) {
	lenList = 1;
	List[lenList] = $0;
	maxlen = length($0);
   } else if (length($0)==maxlen)
	List[++lenList]=$0;
}

END {
   for (k=1; k <= lenList; k++) print List[k];
}


DO
   READ test$
   IF test$ = "~" THEN EXIT DO
   IF LEN(test$) > LEN(test1$) THEN
      test1$ = test$
      test2$ = test1$ + CHR$(10)
   ELSEIF LEN(test$) = LEN(test1$) THEN
      LET test2$ = test2$ + test$ + CHR$(10)
   END IF
LOOP

PRINT (test2$)

DATA "a", "bb", "ccc", "ddd", "ee", "f", "ggg", "~" : ' la tilde es solo para mantener el código compacto


      DIM buffer% 65535
      bufptr% = buffer%
      longest$ = " "

      ON ERROR PRINT $$buffer%; : END

      REPEAT
        READ A$
        IF FNcmp(A$, longest$) THEN
          IF FNcmp(longest$, A$) ELSE bufptr% = buffer%
          longest$ = A$
          $bufptr% = A$
          WHILE ?bufptr%
            bufptr% = FNinc(bufptr%)
          ENDWHILE
          ?bufptr% = 10
          bufptr% = FNinc(bufptr%)
        ENDIF
      UNTIL FALSE : REM Loops until 'Out of data' error
      END

      DATA a, bb, ccc, ddd, ee, f, ggg

      DEF FNcmp(a$, b$) : REM Returns LEN(a$)>=LEN(b$) [if b$<>""]
      LEFT$(a$, 65535) = b$
      = INSTR(a$, b$)

      DEF FNinc(i%) : REM Returns i%+1
      FOR i% = i% TO i% : NEXT
      = i%


#include <stdio.h>
#include <string.h>

int cmp(const char *p, const char *q)
{
	while (*p && *q) p = &p[1], q = &q[1];
	return *p;
}

int main()
{
	char line[65536];
	char buf[1000000] = {0};
	char *last = buf;
	char *next = buf;

	while (gets(line)) {
		strcat(line, "\n");
		if (cmp(last, line)) continue;
		if (cmp(line, last)) next = buf;
		last = next;
		strcpy(next, line);
		while (*next) next = &next[1];
	}

	printf("%s", buf);
	return 0;
}


#include <iostream>
#include <string.h>

int main()
{
    std::string longLine, longestLines, newLine;

    while (std::cin >> newLine)
    {
        auto isNewLineShorter = longLine.c_str();
        auto isLongLineShorter = newLine.c_str();
        while (*isNewLineShorter && *isLongLineShorter)
        {
            // This determines which string is longer without using a built
            // in string length function.  The loop will stop at the 0 at the
            // end of the shortest string.
            isNewLineShorter = &isNewLineShorter[1];
            isLongLineShorter = &isLongLineShorter[1];
        }

        if(*isNewLineShorter) continue; // other lines were longer, do nothing
        if(*isLongLineShorter)
        {
            // the new string is the longest so far
            longLine = newLine;
            longestLines = newLine;
        }
        else
        {
            // the new string is the same lenth as the previous longest
            longestLines+=newLine;
        }
        longestLines+="\n"; // append a new line between the strings
    }

    std::cout << "\nLongest string:\n" << longestLines;
}


ns longest-string
  (:gen-class))

(defn longer [a b]
  " if a is longer, it returns the characters in a after length b characters have been removed
    otherwise it returns nil "
  (if (or (empty? a) (empty? b))
    (not-empty a)
    (recur (rest a) (rest b))))

(defn get-input []
  " Gets the data from standard input as a lazy-sequence of lines (i.e. reads lines as needed by caller
    Input is terminated by a zero length line (i.e. line with just <CR> "
  (let [line (read-line)]
    (if (> (count line) 0)
      (lazy-seq (cons line (get-input)))
      nil)))

(defn process []
  " Returns list of longest lines "
  (first                                                             ; takes lines from [lines longest]
    (reduce (fn [[lines longest] x]
             (cond
              (longer x longest) [x x]                               ; new longer line
              (not (longer longest x)) [(str lines "\n" x) longest] ; append x to previous longest
              :else [lines longest]))                               ; keep previous lines & longest
            ["" ""] (get-input))))

(println "Input text:")
(println "Output:\n" (process))