WeixiangYan/CodeTransOcean huggingface dataset:
Task: Digital root







Python: def digital_root (n):
    ap = 0
    n = abs(int(n))
    while n >= 10:
        n = sum(int(digit) for digit in str(n))
        ap += 1
    return ap, n

if __name__ == '__main__':
    for n in [627615, 39390, 588225, 393900588225, 55]:
        persistance, root = digital_root(n)
        print("%12i has additive persistance %2i and digital root %i." 
              % (n, persistance, root))



COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. DIGITAL-ROOT.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 VARIABLES.
          03 INPUT-NUMBER     PIC 9(16).
          03 INPUT-DIGITS     REDEFINES INPUT-NUMBER,
                              PIC 9 OCCURS 16 TIMES.
          03 DIGIT-SUM        PIC 999.
          03 DIGIT-NO         PIC 99.
          03 PERSISTENCE      PIC 9.

       01 OUTPUT-FORMAT.
          03 O-NUMBER         PIC Z(15)9.
          03 FILLER           PIC X(16) VALUE ': PERSISTENCE = '.
          03 O-PERSISTENCE    PIC Z9.
          03 FILLER           PIC X(9) VALUE ', ROOT = '.
          03 O-ROOT           PIC Z9.

       PROCEDURE DIVISION.
       BEGIN.
           MOVE 627615 TO INPUT-NUMBER, PERFORM FIND-DIGITAL-ROOT.
           MOVE 39390 TO INPUT-NUMBER, PERFORM FIND-DIGITAL-ROOT.
           MOVE 588225 TO INPUT-NUMBER, PERFORM FIND-DIGITAL-ROOT.
           MOVE 393900588225 TO INPUT-NUMBER, PERFORM FIND-DIGITAL-ROOT.
           STOP RUN.

       FIND-DIGITAL-ROOT.
           MOVE ZERO TO PERSISTENCE.
           MOVE INPUT-NUMBER TO O-NUMBER.
           PERFORM SUMMATION UNTIL INPUT-NUMBER IS LESS THAN 10.
           MOVE INPUT-NUMBER TO O-ROOT.
           MOVE PERSISTENCE TO O-PERSISTENCE.
           DISPLAY OUTPUT-FORMAT.

       SUMMATION.
           MOVE ZERO TO DIGIT-SUM.
           ADD 1 TO PERSISTENCE.
           PERFORM ADD-DIGIT VARYING DIGIT-NO FROM 1 BY 1
               UNTIL DIGIT-NO IS GREATER THAN 16.
           MOVE DIGIT-SUM TO INPUT-NUMBER.

       ADD-DIGIT.
           ADD INPUT-DIGITS(DIGIT-NO) TO DIGIT-SUM.
Task: Digital root








VB: Option Base 1
Private Sub digital_root(n As Variant)
    Dim s As String, t() As Integer
    s = CStr(n)
    ReDim t(Len(s))
    For i = 1 To Len(s)
        t(i) = Mid(s, i, 1)
    Next i
    Do
        dr = WorksheetFunction.Sum(t)
        s = CStr(dr)
        ReDim t(Len(s))
        For i = 1 To Len(s)
            t(i) = Mid(s, i, 1)
        Next i
        persistence = persistence + 1
    Loop Until Len(s) = 1
    Debug.Print n; "has additive persistence"; persistence; "and digital root of "; dr & ";"
End Sub
Public Sub main()
    digital_root 627615
    digital_root 39390
    digital_root 588225
    digital_root 393900588225#
End Sub


COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. DIGITAL-ROOT.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 VARIABLES.
          03 INPUT-NUMBER     PIC 9(16).
          03 INPUT-DIGITS     REDEFINES INPUT-NUMBER,
                              PIC 9 OCCURS 16 TIMES.
          03 DIGIT-SUM        PIC 999.
          03 DIGIT-NO         PIC 99.
          03 PERSISTENCE      PIC 9.

       01 OUTPUT-FORMAT.
          03 O-NUMBER         PIC Z(15)9.
          03 FILLER           PIC X(16) VALUE ': PERSISTENCE = '.
          03 O-PERSISTENCE    PIC Z9.
          03 FILLER           PIC X(9) VALUE ', ROOT = '.
          03 O-ROOT           PIC Z9.

       PROCEDURE DIVISION.
       BEGIN.
           MOVE 627615 TO INPUT-NUMBER, PERFORM FIND-DIGITAL-ROOT.
           MOVE 39390 TO INPUT-NUMBER, PERFORM FIND-DIGITAL-ROOT.
           MOVE 588225 TO INPUT-NUMBER, PERFORM FIND-DIGITAL-ROOT.
           MOVE 393900588225 TO INPUT-NUMBER, PERFORM FIND-DIGITAL-ROOT.
           STOP RUN.

       FIND-DIGITAL-ROOT.
           MOVE ZERO TO PERSISTENCE.
           MOVE INPUT-NUMBER TO O-NUMBER.
           PERFORM SUMMATION UNTIL INPUT-NUMBER IS LESS THAN 10.
           MOVE INPUT-NUMBER TO O-ROOT.
           MOVE PERSISTENCE TO O-PERSISTENCE.
           DISPLAY OUTPUT-FORMAT.

       SUMMATION.
           MOVE ZERO TO DIGIT-SUM.
           ADD 1 TO PERSISTENCE.
           PERFORM ADD-DIGIT VARYING DIGIT-NO FROM 1 BY 1
               UNTIL DIGIT-NO IS GREATER THAN 16.
           MOVE DIGIT-SUM TO INPUT-NUMBER.

       ADD-DIGIT.
           ADD INPUT-DIGITS(DIGIT-NO) TO DIGIT-SUM.
Task: Digital root




Go: package main

import (
	"fmt"
	"log"
	"strconv"
)

func Sum(i uint64, base int) (sum int) {
	b64 := uint64(base)
	for ; i > 0; i /= b64 {
		sum += int(i % b64)
	}
	return
}

func DigitalRoot(n uint64, base int) (persistence, root int) {
	root = int(n)
	for x := n; x >= uint64(base); x = uint64(root) {
		root = Sum(x, base)
		persistence++
	}
	return
}




var testCases = []struct {
	n           string
	base        int
	persistence int
	root        int
}{
	{"627615", 10, 2, 9},
	{"39390", 10, 2, 6},
	{"588225", 10, 2, 3},
	{"393900588225", 10, 2, 9},
	{"1", 10, 0, 1},
	{"11", 10, 1, 2},
	{"e", 16, 0, 0xe},
	{"87", 16, 1, 0xf},
	
	{"DigitalRoot", 30, 2, 26}, 
	
	{"448944221089", 10, 3, 1},
	{"7e0", 16, 2, 0x6},
	{"14e344", 16, 2, 0xf},
	{"d60141", 16, 2, 0xa},
	{"12343210", 16, 2, 0x1},
	
	{"1101122201121110011000000", 3, 3, 1},
}

func main() {
	for _, tc := range testCases {
		n, err := strconv.ParseUint(tc.n, tc.base, 64)
		if err != nil {
			log.Fatal(err)
		}
		p, r := DigitalRoot(n, tc.base)
		fmt.Printf("%12v (base %2d) has additive persistence %d and digital root %s\n",
			tc.n, tc.base, p, strconv.FormatInt(int64(r), tc.base))
		if p != tc.persistence || r != tc.root {
			log.Fatalln("bad result:", tc, p, r)
		}
	}
}






COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. DIGITAL-ROOT.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 VARIABLES.
          03 INPUT-NUMBER     PIC 9(16).
          03 INPUT-DIGITS     REDEFINES INPUT-NUMBER,
                              PIC 9 OCCURS 16 TIMES.
          03 DIGIT-SUM        PIC 999.
          03 DIGIT-NO         PIC 99.
          03 PERSISTENCE      PIC 9.

       01 OUTPUT-FORMAT.
          03 O-NUMBER         PIC Z(15)9.
          03 FILLER           PIC X(16) VALUE ': PERSISTENCE = '.
          03 O-PERSISTENCE    PIC Z9.
          03 FILLER           PIC X(9) VALUE ', ROOT = '.
          03 O-ROOT           PIC Z9.

       PROCEDURE DIVISION.
       BEGIN.
           MOVE 627615 TO INPUT-NUMBER, PERFORM FIND-DIGITAL-ROOT.
           MOVE 39390 TO INPUT-NUMBER, PERFORM FIND-DIGITAL-ROOT.
           MOVE 588225 TO INPUT-NUMBER, PERFORM FIND-DIGITAL-ROOT.
           MOVE 393900588225 TO INPUT-NUMBER, PERFORM FIND-DIGITAL-ROOT.
           STOP RUN.

       FIND-DIGITAL-ROOT.
           MOVE ZERO TO PERSISTENCE.
           MOVE INPUT-NUMBER TO O-NUMBER.
           PERFORM SUMMATION UNTIL INPUT-NUMBER IS LESS THAN 10.
           MOVE INPUT-NUMBER TO O-ROOT.
           MOVE PERSISTENCE TO O-PERSISTENCE.
           DISPLAY OUTPUT-FORMAT.

       SUMMATION.
           MOVE ZERO TO DIGIT-SUM.
           ADD 1 TO PERSISTENCE.
           PERFORM ADD-DIGIT VARYING DIGIT-NO FROM 1 BY 1
               UNTIL DIGIT-NO IS GREATER THAN 16.
           MOVE DIGIT-SUM TO INPUT-NUMBER.

       ADD-DIGIT.
           ADD INPUT-DIGITS(DIGIT-NO) TO DIGIT-SUM.
Task: Digital root






PHP: <?php


function rootAndPers($n, $bas)

{
    $pers = 0;
    while ($n >= $bas) {
        $s = 0;
        do {
            $s += $n % $bas;
            $n = floor($n / $bas);
        } while ($n > 0);
        $pers++;
        $n = $s;
    }
    return array($n, $pers);
}

foreach ([1, 14, 267, 8128, 39390, 588225, 627615] as $a) {
    list($root, $pers) = rootAndPers($a, 10);
    echo str_pad($a, 7, ' ', STR_PAD_LEFT);
    echo str_pad($pers, 6, ' ', STR_PAD_LEFT);
    echo str_pad($root, 6, ' ', STR_PAD_LEFT), PHP_EOL;
} 
?>
Task: Digital root






PHP: <?php


function rootAndPers($n, $bas)

{
    $pers = 0;
    while ($n >= $bas) {
        $s = 0;
        do {
            $s += $n % $bas;
            $n = floor($n / $bas);
        } while ($n > 0);
        $pers++;
        $n = $s;
    }
    return array($n, $pers);
}

foreach ([1, 14, 267, 8128, 39390, 588225, 627615] as $a) {
    list($root, $pers) = rootAndPers($a, 10);
    echo str_pad($a, 7, ' ', STR_PAD_LEFT);
    echo str_pad($pers, 6, ' ', STR_PAD_LEFT);
    echo str_pad($root, 6, ' ', STR_PAD_LEFT), PHP_EOL;
} 
?>






Ada: package Generic_Root is 
   type Number is range 0 .. 2**63-1;
   type Number_Array is array(Positive range <>) of Number;
   type Base_Type is range 2 .. 16; 
   
   generic
      with function "&"(X, Y: Number) return Number;
      
      
   procedure Compute_Root(N: Number; 
                     Root, Persistence: out Number;
                     Base: Base_Type := 10);
   
   
end Generic_Root;
Task: Digital root






PHP: <?php


function rootAndPers($n, $bas)

{
    $pers = 0;
    while ($n >= $bas) {
        $s = 0;
        do {
            $s += $n % $bas;
            $n = floor($n / $bas);
        } while ($n > 0);
        $pers++;
        $n = $s;
    }
    return array($n, $pers);
}

foreach ([1, 14, 267, 8128, 39390, 588225, 627615] as $a) {
    list($root, $pers) = rootAndPers($a, 10);
    echo str_pad($a, 7, ' ', STR_PAD_LEFT);
    echo str_pad($pers, 6, ' ', STR_PAD_LEFT);
    echo str_pad($root, 6, ' ', STR_PAD_LEFT), PHP_EOL;
} 
?>




COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. DIGITAL-ROOT.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 VARIABLES.
          03 INPUT-NUMBER     PIC 9(16).
          03 INPUT-DIGITS     REDEFINES INPUT-NUMBER,
                              PIC 9 OCCURS 16 TIMES.
          03 DIGIT-SUM        PIC 999.
          03 DIGIT-NO         PIC 99.
          03 PERSISTENCE      PIC 9.

       01 OUTPUT-FORMAT.
          03 O-NUMBER         PIC Z(15)9.
          03 FILLER           PIC X(16) VALUE ': PERSISTENCE = '.
          03 O-PERSISTENCE    PIC Z9.
          03 FILLER           PIC X(9) VALUE ', ROOT = '.
          03 O-ROOT           PIC Z9.

       PROCEDURE DIVISION.
       BEGIN.
           MOVE 627615 TO INPUT-NUMBER, PERFORM FIND-DIGITAL-ROOT.
           MOVE 39390 TO INPUT-NUMBER, PERFORM FIND-DIGITAL-ROOT.
           MOVE 588225 TO INPUT-NUMBER, PERFORM FIND-DIGITAL-ROOT.
           MOVE 393900588225 TO INPUT-NUMBER, PERFORM FIND-DIGITAL-ROOT.
           STOP RUN.

       FIND-DIGITAL-ROOT.
           MOVE ZERO TO PERSISTENCE.
           MOVE INPUT-NUMBER TO O-NUMBER.
           PERFORM SUMMATION UNTIL INPUT-NUMBER IS LESS THAN 10.
           MOVE INPUT-NUMBER TO O-ROOT.
           MOVE PERSISTENCE TO O-PERSISTENCE.
           DISPLAY OUTPUT-FORMAT.

       SUMMATION.
           MOVE ZERO TO DIGIT-SUM.
           ADD 1 TO PERSISTENCE.
           PERFORM ADD-DIGIT VARYING DIGIT-NO FROM 1 BY 1
               UNTIL DIGIT-NO IS GREATER THAN 16.
           MOVE DIGIT-SUM TO INPUT-NUMBER.

       ADD-DIGIT.
           ADD INPUT-DIGITS(DIGIT-NO) TO DIGIT-SUM.
Task: Loops_Continue



C#: using System;

class Program {
    static void Main(string[] args) {
        for (int i = 1; i <= 10; i++) {
            Console.Write(i);

            if (i % 5 == 0) {
                Console.WriteLine();
                continue;
            }

            Console.Write(", ");
        }
    }
}









Ada: with Ada.Text_IO;
use Ada.Text_IO;

procedure Loop_Continue is
begin
        for I in 1..10 loop
                Put (Integer'Image(I));
                if I = 5 or I = 10 then
                        New_Line;
                        goto Continue;
                end if;
                Put (",");
                <<Continue>>  
        end loop;
end Loop_Continue;
Task: Loops_Continue

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











Ada: with Ada.Text_IO;
use Ada.Text_IO;

procedure Loop_Continue is
begin
        for I in 1..10 loop
                Put (Integer'Image(I));
                if I = 5 or I = 10 then
                        New_Line;
                        goto Continue;
                end if;
                Put (",");
                <<Continue>>  
        end loop;
end Loop_Continue;
Task: Loops_Continue


C++: for(int i = 1;i <= 10; i++){
   cout << i;
   if(i % 5 == 0){
      cout << endl;
      continue;
   }
   cout << ", ";
}










Ada: with Ada.Text_IO;
use Ada.Text_IO;

procedure Loop_Continue is
begin
        for I in 1..10 loop
                Put (Integer'Image(I));
                if I = 5 or I = 10 then
                        New_Line;
                        goto Continue;
                end if;
                Put (",");
                <<Continue>>  
        end loop;
end Loop_Continue;
Task: Loops_Continue




Go: 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(", ")
    }
}








Ada: with Ada.Text_IO;
use Ada.Text_IO;

procedure Loop_Continue is
begin
        for I in 1..10 loop
                Put (Integer'Image(I));
                if I = 5 or I = 10 then
                        New_Line;
                        goto Continue;
                end if;
                Put (",");
                <<Continue>>  
        end loop;
end Loop_Continue;
Task: Loops_Continue





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







Ada: with Ada.Text_IO;
use Ada.Text_IO;

procedure Loop_Continue is
begin
        for I in 1..10 loop
                Put (Integer'Image(I));
                if I = 5 or I = 10 then
                        New_Line;
                        goto Continue;
                end if;
                Put (",");
                <<Continue>>  
        end loop;
end Loop_Continue;
Task: Loops_Continue







Python: for i in range(1, 11):
    if i % 5 == 0:
        print(i)
        continue
    print(i, end=', ')





Ada: with Ada.Text_IO;
use Ada.Text_IO;

procedure Loop_Continue is
begin
        for I in 1..10 loop
                Put (Integer'Image(I));
                if I = 5 or I = 10 then
                        New_Line;
                        goto Continue;
                end if;
                Put (",");
                <<Continue>>  
        end loop;
end Loop_Continue;
Task: Loops_Continue








VB: For i = 1 To 10
    Console.Write(i)
    If i Mod 5 = 0 Then
        Console.WriteLine()
    Else
        Console.Write(", ")
    End If
Next




Ada: with Ada.Text_IO;
use Ada.Text_IO;

procedure Loop_Continue is
begin
        for I in 1..10 loop
                Put (Integer'Image(I));
                if I = 5 or I = 10 then
                        New_Line;
                        goto Continue;
                end if;
                Put (",");
                <<Continue>>  
        end loop;
end Loop_Continue;
Task: Loops_Continue

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



C#: using System;

class Program {
    static void Main(string[] args) {
        for (int i = 1; i <= 10; i++) {
            Console.Write(i);

            if (i % 5 == 0) {
                Console.WriteLine();
                continue;
            }

            Console.Write(", ");
        }
    }
}
Task: Loops_Continue


C++: for(int i = 1;i <= 10; i++){
   cout << i;
   if(i % 5 == 0){
      cout << endl;
      continue;
   }
   cout << ", ";
}
Task: Loops_Continue





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







Python: for i in range(1, 11):
    if i % 5 == 0:
        print(i)
        continue
    print(i, end=', ')
Task: Loops_Continue








VB: For i = 1 To 10
    Console.Write(i)
    If i Mod 5 = 0 Then
        Console.WriteLine()
    Else
        Console.Write(", ")
    End If
Next
Task: Loops_Continue




Go: 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(", ")
    }
}
Task: Loops_Continue



C#: using System;

class Program {
    static void Main(string[] args) {
        for (int i = 1; i <= 10; i++) {
            Console.Write(i);

            if (i % 5 == 0) {
                Console.WriteLine();
                continue;
            }

            Console.Write(", ");
        }
    }
}








Fortran: do i = 1, 10
   write(*, '(I0)', advance='no') i
   if ( mod(i, 5) == 0 ) then
      write(*,*)
      cycle
   end if
   write(*, '(A)', advance='no') ', '
end do
Task: Loops_Continue


C++: for(int i = 1;i <= 10; i++){
   cout << i;
   if(i % 5 == 0){
      cout << endl;
      continue;
   }
   cout << ", ";
}









Fortran: do i = 1, 10
   write(*, '(I0)', advance='no') i
   if ( mod(i, 5) == 0 ) then
      write(*,*)
      cycle
   end if
   write(*, '(A)', advance='no') ', '
end do
Task: Loops_Continue

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










Fortran: do i = 1, 10
   write(*, '(I0)', advance='no') i
   if ( mod(i, 5) == 0 ) then
      write(*,*)
      cycle
   end if
   write(*, '(A)', advance='no') ', '
end do
Task: Loops_Continue





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






Fortran: do i = 1, 10
   write(*, '(I0)', advance='no') i
   if ( mod(i, 5) == 0 ) then
      write(*,*)
      cycle
   end if
   write(*, '(A)', advance='no') ', '
end do
Task: Loops_Continue







Python: for i in range(1, 11):
    if i % 5 == 0:
        print(i)
        continue
    print(i, end=', ')




Fortran: do i = 1, 10
   write(*, '(I0)', advance='no') i
   if ( mod(i, 5) == 0 ) then
      write(*,*)
      cycle
   end if
   write(*, '(A)', advance='no') ', '
end do
Task: Loops_Continue








VB: For i = 1 To 10
    Console.Write(i)
    If i Mod 5 = 0 Then
        Console.WriteLine()
    Else
        Console.Write(", ")
    End If
Next



Fortran: do i = 1, 10
   write(*, '(I0)', advance='no') i
   if ( mod(i, 5) == 0 ) then
      write(*,*)
      cycle
   end if
   write(*, '(A)', advance='no') ', '
end do
Task: Loops_Continue






PHP: for ($i = 1; $i <= 10; $i++) {
    echo $i;
    if ($i % 5 == 0) {
        echo "\n";
        continue;
    }
    echo ', ';
}





Fortran: do i = 1, 10
   write(*, '(I0)', advance='no') i
   if ( mod(i, 5) == 0 ) then
      write(*,*)
      cycle
   end if
   write(*, '(A)', advance='no') ', '
end do
Task: Loops_Continue

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









COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. loop-continue.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  i PIC 99.

       PROCEDURE DIVISION.
           PERFORM VARYING i FROM 1 BY 1 UNTIL 10 < i
               DISPLAY i WITH NO ADVANCING

               IF FUNCTION MOD(i, 5) = 0
                   DISPLAY SPACE
                   EXIT PERFORM CYCLE
               END-IF

               DISPLAY ", " WITH NO ADVANCING
           END-PERFORM

           GOBACK
           .
Task: Loops_Continue



C#: using System;

class Program {
    static void Main(string[] args) {
        for (int i = 1; i <= 10; i++) {
            Console.Write(i);

            if (i % 5 == 0) {
                Console.WriteLine();
                continue;
            }

            Console.Write(", ");
        }
    }
}







COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. loop-continue.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  i PIC 99.

       PROCEDURE DIVISION.
           PERFORM VARYING i FROM 1 BY 1 UNTIL 10 < i
               DISPLAY i WITH NO ADVANCING

               IF FUNCTION MOD(i, 5) = 0
                   DISPLAY SPACE
                   EXIT PERFORM CYCLE
               END-IF

               DISPLAY ", " WITH NO ADVANCING
           END-PERFORM

           GOBACK
           .
Task: Loops_Continue


C++: for(int i = 1;i <= 10; i++){
   cout << i;
   if(i % 5 == 0){
      cout << endl;
      continue;
   }
   cout << ", ";
}








COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. loop-continue.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  i PIC 99.

       PROCEDURE DIVISION.
           PERFORM VARYING i FROM 1 BY 1 UNTIL 10 < i
               DISPLAY i WITH NO ADVANCING

               IF FUNCTION MOD(i, 5) = 0
                   DISPLAY SPACE
                   EXIT PERFORM CYCLE
               END-IF

               DISPLAY ", " WITH NO ADVANCING
           END-PERFORM

           GOBACK
           .
Task: Loops_Continue





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





COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. loop-continue.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  i PIC 99.

       PROCEDURE DIVISION.
           PERFORM VARYING i FROM 1 BY 1 UNTIL 10 < i
               DISPLAY i WITH NO ADVANCING

               IF FUNCTION MOD(i, 5) = 0
                   DISPLAY SPACE
                   EXIT PERFORM CYCLE
               END-IF

               DISPLAY ", " WITH NO ADVANCING
           END-PERFORM

           GOBACK
           .
Task: Loops_Continue







Python: for i in range(1, 11):
    if i % 5 == 0:
        print(i)
        continue
    print(i, end=', ')



COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. loop-continue.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  i PIC 99.

       PROCEDURE DIVISION.
           PERFORM VARYING i FROM 1 BY 1 UNTIL 10 < i
               DISPLAY i WITH NO ADVANCING

               IF FUNCTION MOD(i, 5) = 0
                   DISPLAY SPACE
                   EXIT PERFORM CYCLE
               END-IF

               DISPLAY ", " WITH NO ADVANCING
           END-PERFORM

           GOBACK
           .
Task: Loops_Continue








VB: For i = 1 To 10
    Console.Write(i)
    If i Mod 5 = 0 Then
        Console.WriteLine()
    Else
        Console.Write(", ")
    End If
Next


COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. loop-continue.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  i PIC 99.

       PROCEDURE DIVISION.
           PERFORM VARYING i FROM 1 BY 1 UNTIL 10 < i
               DISPLAY i WITH NO ADVANCING

               IF FUNCTION MOD(i, 5) = 0
                   DISPLAY SPACE
                   EXIT PERFORM CYCLE
               END-IF

               DISPLAY ", " WITH NO ADVANCING
           END-PERFORM

           GOBACK
           .
Task: Loops_Continue




Go: 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(", ")
    }
}






COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. loop-continue.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  i PIC 99.

       PROCEDURE DIVISION.
           PERFORM VARYING i FROM 1 BY 1 UNTIL 10 < i
               DISPLAY i WITH NO ADVANCING

               IF FUNCTION MOD(i, 5) = 0
                   DISPLAY SPACE
                   EXIT PERFORM CYCLE
               END-IF

               DISPLAY ", " WITH NO ADVANCING
           END-PERFORM

           GOBACK
           .
Task: Loops_Continue






PHP: for ($i = 1; $i <= 10; $i++) {
    echo $i;
    if ($i % 5 == 0) {
        echo "\n";
        continue;
    }
    echo ', ';
}