WeixiangYan/CodeTransOcean huggingface dataset:
Task: Count in octal



C#: using System;

class Program
{
    static void Main()
    {
        var number = 0;
        do
        {
            Console.WriteLine(Convert.ToString(number, 8));
        } while (++number > 0);
    }
}







COBOL:        >>SOURCE FREE
IDENTIFICATION DIVISION.
PROGRAM-ID. count-in-octal.

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
REPOSITORY.
    FUNCTION dec-to-oct
    .
DATA DIVISION.
WORKING-STORAGE SECTION.
01  i                                   PIC 9(18).

PROCEDURE DIVISION.
    PERFORM VARYING i FROM 1 BY 1 UNTIL i = 0
        DISPLAY FUNCTION dec-to-oct(i)
    END-PERFORM
    .
END PROGRAM count-in-octal.


IDENTIFICATION DIVISION.
FUNCTION-ID. dec-to-oct.

DATA DIVISION.
LOCAL-STORAGE SECTION.
01  rem                                 PIC 9.

01  dec                                 PIC 9(18).

LINKAGE SECTION.
01  dec-arg                             PIC 9(18).

01  oct                                 PIC 9(18).

PROCEDURE DIVISION USING dec-arg RETURNING oct.
    MOVE dec-arg TO dec 
    PERFORM WITH TEST AFTER UNTIL dec = 0
        MOVE FUNCTION REM(dec, 8) TO rem
        STRING rem, oct DELIMITED BY SPACES INTO oct
        DIVIDE 8 INTO dec
    END-PERFORM
    .
END FUNCTION dec-to-oct.
Task: Count in octal


C++: #include <iostream>

int main()
{
  unsigned i = 0;
  do
  {
    std::cout << std::oct << i << std::endl;
    ++i;
  } while(i != 0);
  return 0;
}








COBOL:        >>SOURCE FREE
IDENTIFICATION DIVISION.
PROGRAM-ID. count-in-octal.

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
REPOSITORY.
    FUNCTION dec-to-oct
    .
DATA DIVISION.
WORKING-STORAGE SECTION.
01  i                                   PIC 9(18).

PROCEDURE DIVISION.
    PERFORM VARYING i FROM 1 BY 1 UNTIL i = 0
        DISPLAY FUNCTION dec-to-oct(i)
    END-PERFORM
    .
END PROGRAM count-in-octal.


IDENTIFICATION DIVISION.
FUNCTION-ID. dec-to-oct.

DATA DIVISION.
LOCAL-STORAGE SECTION.
01  rem                                 PIC 9.

01  dec                                 PIC 9(18).

LINKAGE SECTION.
01  dec-arg                             PIC 9(18).

01  oct                                 PIC 9(18).

PROCEDURE DIVISION USING dec-arg RETURNING oct.
    MOVE dec-arg TO dec 
    PERFORM WITH TEST AFTER UNTIL dec = 0
        MOVE FUNCTION REM(dec, 8) TO rem
        STRING rem, oct DELIMITED BY SPACES INTO oct
        DIVIDE 8 INTO dec
    END-PERFORM
    .
END FUNCTION dec-to-oct.
Task: Count in octal





Java: public class Count{
    public static void main(String[] args){
        for(int i = 0;i >= 0;i++){
            System.out.println(Integer.toOctalString(i)); 
        }
    }
}





COBOL:        >>SOURCE FREE
IDENTIFICATION DIVISION.
PROGRAM-ID. count-in-octal.

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
REPOSITORY.
    FUNCTION dec-to-oct
    .
DATA DIVISION.
WORKING-STORAGE SECTION.
01  i                                   PIC 9(18).

PROCEDURE DIVISION.
    PERFORM VARYING i FROM 1 BY 1 UNTIL i = 0
        DISPLAY FUNCTION dec-to-oct(i)
    END-PERFORM
    .
END PROGRAM count-in-octal.


IDENTIFICATION DIVISION.
FUNCTION-ID. dec-to-oct.

DATA DIVISION.
LOCAL-STORAGE SECTION.
01  rem                                 PIC 9.

01  dec                                 PIC 9(18).

LINKAGE SECTION.
01  dec-arg                             PIC 9(18).

01  oct                                 PIC 9(18).

PROCEDURE DIVISION USING dec-arg RETURNING oct.
    MOVE dec-arg TO dec 
    PERFORM WITH TEST AFTER UNTIL dec = 0
        MOVE FUNCTION REM(dec, 8) TO rem
        STRING rem, oct DELIMITED BY SPACES INTO oct
        DIVIDE 8 INTO dec
    END-PERFORM
    .
END FUNCTION dec-to-oct.
Task: Count in octal







Python: import sys
for n in xrange(sys.maxint):
    print oct(n)



COBOL:        >>SOURCE FREE
IDENTIFICATION DIVISION.
PROGRAM-ID. count-in-octal.

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
REPOSITORY.
    FUNCTION dec-to-oct
    .
DATA DIVISION.
WORKING-STORAGE SECTION.
01  i                                   PIC 9(18).

PROCEDURE DIVISION.
    PERFORM VARYING i FROM 1 BY 1 UNTIL i = 0
        DISPLAY FUNCTION dec-to-oct(i)
    END-PERFORM
    .
END PROGRAM count-in-octal.


IDENTIFICATION DIVISION.
FUNCTION-ID. dec-to-oct.

DATA DIVISION.
LOCAL-STORAGE SECTION.
01  rem                                 PIC 9.

01  dec                                 PIC 9(18).

LINKAGE SECTION.
01  dec-arg                             PIC 9(18).

01  oct                                 PIC 9(18).

PROCEDURE DIVISION USING dec-arg RETURNING oct.
    MOVE dec-arg TO dec 
    PERFORM WITH TEST AFTER UNTIL dec = 0
        MOVE FUNCTION REM(dec, 8) TO rem
        STRING rem, oct DELIMITED BY SPACES INTO oct
        DIVIDE 8 INTO dec
    END-PERFORM
    .
END FUNCTION dec-to-oct.
Task: Count in octal








VB: For i = 0 To 20
	WScript.StdOut.WriteLine Oct(i)
Next


COBOL:        >>SOURCE FREE
IDENTIFICATION DIVISION.
PROGRAM-ID. count-in-octal.

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
REPOSITORY.
    FUNCTION dec-to-oct
    .
DATA DIVISION.
WORKING-STORAGE SECTION.
01  i                                   PIC 9(18).

PROCEDURE DIVISION.
    PERFORM VARYING i FROM 1 BY 1 UNTIL i = 0
        DISPLAY FUNCTION dec-to-oct(i)
    END-PERFORM
    .
END PROGRAM count-in-octal.


IDENTIFICATION DIVISION.
FUNCTION-ID. dec-to-oct.

DATA DIVISION.
LOCAL-STORAGE SECTION.
01  rem                                 PIC 9.

01  dec                                 PIC 9(18).

LINKAGE SECTION.
01  dec-arg                             PIC 9(18).

01  oct                                 PIC 9(18).

PROCEDURE DIVISION USING dec-arg RETURNING oct.
    MOVE dec-arg TO dec 
    PERFORM WITH TEST AFTER UNTIL dec = 0
        MOVE FUNCTION REM(dec, 8) TO rem
        STRING rem, oct DELIMITED BY SPACES INTO oct
        DIVIDE 8 INTO dec
    END-PERFORM
    .
END FUNCTION dec-to-oct.
Task: Count in octal




Go: package main

import (
    "fmt"
    "math"
)

func main() {
    for i := int8(0); ; i++ {
        fmt.Printf("%o\n", i)
        if i == math.MaxInt8 {
            break
        }
    }
}






COBOL:        >>SOURCE FREE
IDENTIFICATION DIVISION.
PROGRAM-ID. count-in-octal.

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
REPOSITORY.
    FUNCTION dec-to-oct
    .
DATA DIVISION.
WORKING-STORAGE SECTION.
01  i                                   PIC 9(18).

PROCEDURE DIVISION.
    PERFORM VARYING i FROM 1 BY 1 UNTIL i = 0
        DISPLAY FUNCTION dec-to-oct(i)
    END-PERFORM
    .
END PROGRAM count-in-octal.


IDENTIFICATION DIVISION.
FUNCTION-ID. dec-to-oct.

DATA DIVISION.
LOCAL-STORAGE SECTION.
01  rem                                 PIC 9.

01  dec                                 PIC 9(18).

LINKAGE SECTION.
01  dec-arg                             PIC 9(18).

01  oct                                 PIC 9(18).

PROCEDURE DIVISION USING dec-arg RETURNING oct.
    MOVE dec-arg TO dec 
    PERFORM WITH TEST AFTER UNTIL dec = 0
        MOVE FUNCTION REM(dec, 8) TO rem
        STRING rem, oct DELIMITED BY SPACES INTO oct
        DIVIDE 8 INTO dec
    END-PERFORM
    .
END FUNCTION dec-to-oct.
Task: Count in octal






PHP: <?php
for ($n = 0; is_int($n); $n++) {
  echo decoct($n), "\n";
}
?>
Task: Count in octal






PHP: <?php
for ($n = 0; is_int($n); $n++) {
  echo decoct($n), "\n";
}
?>






Ada: with Ada.Text_IO;

procedure Octal is
   package IIO is new Ada.Text_IO.Integer_IO(Integer);
begin
   for I in 0 .. Integer'Last loop
      IIO.Put(I, Base => 8);
      Ada.Text_IO.New_Line;
   end loop;
end Octal;
Task: Count in octal






PHP: <?php
for ($n = 0; is_int($n); $n++) {
  echo decoct($n), "\n";
}
?>




COBOL:        >>SOURCE FREE
IDENTIFICATION DIVISION.
PROGRAM-ID. count-in-octal.

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
REPOSITORY.
    FUNCTION dec-to-oct
    .
DATA DIVISION.
WORKING-STORAGE SECTION.
01  i                                   PIC 9(18).

PROCEDURE DIVISION.
    PERFORM VARYING i FROM 1 BY 1 UNTIL i = 0
        DISPLAY FUNCTION dec-to-oct(i)
    END-PERFORM
    .
END PROGRAM count-in-octal.


IDENTIFICATION DIVISION.
FUNCTION-ID. dec-to-oct.

DATA DIVISION.
LOCAL-STORAGE SECTION.
01  rem                                 PIC 9.

01  dec                                 PIC 9(18).

LINKAGE SECTION.
01  dec-arg                             PIC 9(18).

01  oct                                 PIC 9(18).

PROCEDURE DIVISION USING dec-arg RETURNING oct.
    MOVE dec-arg TO dec 
    PERFORM WITH TEST AFTER UNTIL dec = 0
        MOVE FUNCTION REM(dec, 8) TO rem
        STRING rem, oct DELIMITED BY SPACES INTO oct
        DIVIDE 8 INTO dec
    END-PERFORM
    .
END FUNCTION dec-to-oct.
Task: Delete a file



C#: using System;
using System.IO;

namespace DeleteFile {
  class Program {
    static void Main() {
      File.Delete("input.txt");
      Directory.Delete("docs");
      File.Delete("/input.txt");
      Directory.Delete("/docs");
    }
  }
}









Ada: with Ada.Directories;  use Ada.Directories;
Task: Delete a file

C: #include <stdio.h>

int main() {
  remove("input.txt");
  remove("/input.txt");
  remove("docs");
  remove("/docs");
  return 0;
}











Ada: with Ada.Directories;  use Ada.Directories;
Task: Delete a file


C++: #include <cstdio>
#include <direct.h>

int main() {
	remove( "input.txt" );
	remove( "/input.txt" );
	_rmdir( "docs" );
	_rmdir( "/docs" );

	return 0;
}










Ada: with Ada.Directories;  use Ada.Directories;
Task: Delete a file




Go: package main
import "os"

func main() {
  os.Remove("input.txt")
  os.Remove("/input.txt")
  os.Remove("docs")
  os.Remove("/docs")
  
  os.RemoveAll("docs")
  os.RemoveAll("/docs")
}








Ada: with Ada.Directories;  use Ada.Directories;
Task: Delete a file





Java: import java.io.File;

public class FileDeleteTest {
    public static boolean deleteFile(String filename) {
        boolean exists = new File(filename).delete();
        return exists;
    }
    
    public static void test(String type, String filename) {
        System.out.println("The following " + type + " called " + filename + 
            (deleteFile(filename) ? " was deleted." : " could not be deleted.")
        );
    }

    public static void main(String args[]) {
        test("file", "input.txt");
        test("file", File.seperator + "input.txt");
        test("directory", "docs");
        test("directory", File.seperator + "docs" + File.seperator);
    }
}







Ada: with Ada.Directories;  use Ada.Directories;
Task: Delete a file







Python: import os

os.remove("output.txt")
os.rmdir("docs")

os.remove("/output.txt")
os.rmdir("/docs")





Ada: with Ada.Directories;  use Ada.Directories;
Task: Delete a file








VB: Option Explicit

Sub DeleteFileOrDirectory()
Dim myPath As String
    myPath = "C:\Users\surname.name\Desktop\Docs"

    Kill myPath & "\input.txt"

    RmDir myPath
End Sub




Ada: with Ada.Directories;  use Ada.Directories;
Task: Delete a file

C: #include <stdio.h>

int main() {
  remove("input.txt");
  remove("/input.txt");
  remove("docs");
  remove("/docs");
  return 0;
}
Task: Delete a file



C#: using System;
using System.IO;

namespace DeleteFile {
  class Program {
    static void Main() {
      File.Delete("input.txt");
      Directory.Delete("docs");
      File.Delete("/input.txt");
      Directory.Delete("/docs");
    }
  }
}
Task: Delete a file


C++: #include <cstdio>
#include <direct.h>

int main() {
	remove( "input.txt" );
	remove( "/input.txt" );
	_rmdir( "docs" );
	_rmdir( "/docs" );

	return 0;
}
Task: Delete a file





Java: import java.io.File;

public class FileDeleteTest {
    public static boolean deleteFile(String filename) {
        boolean exists = new File(filename).delete();
        return exists;
    }
    
    public static void test(String type, String filename) {
        System.out.println("The following " + type + " called " + filename + 
            (deleteFile(filename) ? " was deleted." : " could not be deleted.")
        );
    }

    public static void main(String args[]) {
        test("file", "input.txt");
        test("file", File.seperator + "input.txt");
        test("directory", "docs");
        test("directory", File.seperator + "docs" + File.seperator);
    }
}
Task: Delete a file







Python: import os

os.remove("output.txt")
os.rmdir("docs")

os.remove("/output.txt")
os.rmdir("/docs")
Task: Delete a file








VB: Option Explicit

Sub DeleteFileOrDirectory()
Dim myPath As String
    myPath = "C:\Users\surname.name\Desktop\Docs"

    Kill myPath & "\input.txt"

    RmDir myPath
End Sub
Task: Delete a file




Go: package main
import "os"

func main() {
  os.Remove("input.txt")
  os.Remove("/input.txt")
  os.Remove("docs")
  os.Remove("/docs")
  
  os.RemoveAll("docs")
  os.RemoveAll("/docs")
}
Task: Delete a file



C#: using System;
using System.IO;

namespace DeleteFile {
  class Program {
    static void Main() {
      File.Delete("input.txt");
      Directory.Delete("docs");
      File.Delete("/input.txt");
      Directory.Delete("/docs");
    }
  }
}








Fortran:  OPEN  (UNIT=5, FILE="input.txt", STATUS="OLD")   
 CLOSE (UNIT=5, STATUS="DELETE")
 OPEN  (UNIT=5, FILE="/input.txt", STATUS="OLD")  
 CLOSE (UNIT=5, STATUS="DELETE")
Task: Delete a file


C++: #include <cstdio>
#include <direct.h>

int main() {
	remove( "input.txt" );
	remove( "/input.txt" );
	_rmdir( "docs" );
	_rmdir( "/docs" );

	return 0;
}









Fortran:  OPEN  (UNIT=5, FILE="input.txt", STATUS="OLD")   
 CLOSE (UNIT=5, STATUS="DELETE")
 OPEN  (UNIT=5, FILE="/input.txt", STATUS="OLD")  
 CLOSE (UNIT=5, STATUS="DELETE")
Task: Delete a file

C: #include <stdio.h>

int main() {
  remove("input.txt");
  remove("/input.txt");
  remove("docs");
  remove("/docs");
  return 0;
}










Fortran:  OPEN  (UNIT=5, FILE="input.txt", STATUS="OLD")   
 CLOSE (UNIT=5, STATUS="DELETE")
 OPEN  (UNIT=5, FILE="/input.txt", STATUS="OLD")  
 CLOSE (UNIT=5, STATUS="DELETE")
Task: Delete a file





Java: import java.io.File;

public class FileDeleteTest {
    public static boolean deleteFile(String filename) {
        boolean exists = new File(filename).delete();
        return exists;
    }
    
    public static void test(String type, String filename) {
        System.out.println("The following " + type + " called " + filename + 
            (deleteFile(filename) ? " was deleted." : " could not be deleted.")
        );
    }

    public static void main(String args[]) {
        test("file", "input.txt");
        test("file", File.seperator + "input.txt");
        test("directory", "docs");
        test("directory", File.seperator + "docs" + File.seperator);
    }
}






Fortran:  OPEN  (UNIT=5, FILE="input.txt", STATUS="OLD")   
 CLOSE (UNIT=5, STATUS="DELETE")
 OPEN  (UNIT=5, FILE="/input.txt", STATUS="OLD")  
 CLOSE (UNIT=5, STATUS="DELETE")
Task: Delete a file







Python: import os

os.remove("output.txt")
os.rmdir("docs")

os.remove("/output.txt")
os.rmdir("/docs")




Fortran:  OPEN  (UNIT=5, FILE="input.txt", STATUS="OLD")   
 CLOSE (UNIT=5, STATUS="DELETE")
 OPEN  (UNIT=5, FILE="/input.txt", STATUS="OLD")  
 CLOSE (UNIT=5, STATUS="DELETE")
Task: Delete a file








VB: Option Explicit

Sub DeleteFileOrDirectory()
Dim myPath As String
    myPath = "C:\Users\surname.name\Desktop\Docs"

    Kill myPath & "\input.txt"

    RmDir myPath
End Sub



Fortran:  OPEN  (UNIT=5, FILE="input.txt", STATUS="OLD")   
 CLOSE (UNIT=5, STATUS="DELETE")
 OPEN  (UNIT=5, FILE="/input.txt", STATUS="OLD")  
 CLOSE (UNIT=5, STATUS="DELETE")
Task: Delete a file






PHP: <?php
unlink('input.txt');
unlink('/input.txt');
rmdir('docs');
rmdir('/docs');
?>





Fortran:  OPEN  (UNIT=5, FILE="input.txt", STATUS="OLD")   
 CLOSE (UNIT=5, STATUS="DELETE")
 OPEN  (UNIT=5, FILE="/input.txt", STATUS="OLD")  
 CLOSE (UNIT=5, STATUS="DELETE")
Task: Delete a file

C: #include <stdio.h>

int main() {
  remove("input.txt");
  remove("/input.txt");
  remove("docs");
  remove("/docs");
  return 0;
}









COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Delete-Files.

       PROCEDURE DIVISION.
           CALL "CBL_DELETE_FILE" USING "input.txt"
           CALL "CBL_DELETE_DIR"  USING "docs"
           CALL "CBL_DELETE_FILE" USING "/input.txt"
           CALL "CBL_DELETE_DIR"  USING "/docs"

           GOBACK
           .
Task: Delete a file



C#: using System;
using System.IO;

namespace DeleteFile {
  class Program {
    static void Main() {
      File.Delete("input.txt");
      Directory.Delete("docs");
      File.Delete("/input.txt");
      Directory.Delete("/docs");
    }
  }
}







COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Delete-Files.

       PROCEDURE DIVISION.
           CALL "CBL_DELETE_FILE" USING "input.txt"
           CALL "CBL_DELETE_DIR"  USING "docs"
           CALL "CBL_DELETE_FILE" USING "/input.txt"
           CALL "CBL_DELETE_DIR"  USING "/docs"

           GOBACK
           .
Task: Delete a file


C++: #include <cstdio>
#include <direct.h>

int main() {
	remove( "input.txt" );
	remove( "/input.txt" );
	_rmdir( "docs" );
	_rmdir( "/docs" );

	return 0;
}








COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Delete-Files.

       PROCEDURE DIVISION.
           CALL "CBL_DELETE_FILE" USING "input.txt"
           CALL "CBL_DELETE_DIR"  USING "docs"
           CALL "CBL_DELETE_FILE" USING "/input.txt"
           CALL "CBL_DELETE_DIR"  USING "/docs"

           GOBACK
           .
Task: Delete a file





Java: import java.io.File;

public class FileDeleteTest {
    public static boolean deleteFile(String filename) {
        boolean exists = new File(filename).delete();
        return exists;
    }
    
    public static void test(String type, String filename) {
        System.out.println("The following " + type + " called " + filename + 
            (deleteFile(filename) ? " was deleted." : " could not be deleted.")
        );
    }

    public static void main(String args[]) {
        test("file", "input.txt");
        test("file", File.seperator + "input.txt");
        test("directory", "docs");
        test("directory", File.seperator + "docs" + File.seperator);
    }
}





COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Delete-Files.

       PROCEDURE DIVISION.
           CALL "CBL_DELETE_FILE" USING "input.txt"
           CALL "CBL_DELETE_DIR"  USING "docs"
           CALL "CBL_DELETE_FILE" USING "/input.txt"
           CALL "CBL_DELETE_DIR"  USING "/docs"

           GOBACK
           .
Task: Delete a file







Python: import os

os.remove("output.txt")
os.rmdir("docs")

os.remove("/output.txt")
os.rmdir("/docs")



COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Delete-Files.

       PROCEDURE DIVISION.
           CALL "CBL_DELETE_FILE" USING "input.txt"
           CALL "CBL_DELETE_DIR"  USING "docs"
           CALL "CBL_DELETE_FILE" USING "/input.txt"
           CALL "CBL_DELETE_DIR"  USING "/docs"

           GOBACK
           .
Task: Delete a file








VB: Option Explicit

Sub DeleteFileOrDirectory()
Dim myPath As String
    myPath = "C:\Users\surname.name\Desktop\Docs"

    Kill myPath & "\input.txt"

    RmDir myPath
End Sub


COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Delete-Files.

       PROCEDURE DIVISION.
           CALL "CBL_DELETE_FILE" USING "input.txt"
           CALL "CBL_DELETE_DIR"  USING "docs"
           CALL "CBL_DELETE_FILE" USING "/input.txt"
           CALL "CBL_DELETE_DIR"  USING "/docs"

           GOBACK
           .
Task: Delete a file




Go: package main
import "os"

func main() {
  os.Remove("input.txt")
  os.Remove("/input.txt")
  os.Remove("docs")
  os.Remove("/docs")
  
  os.RemoveAll("docs")
  os.RemoveAll("/docs")
}






COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Delete-Files.

       PROCEDURE DIVISION.
           CALL "CBL_DELETE_FILE" USING "input.txt"
           CALL "CBL_DELETE_DIR"  USING "docs"
           CALL "CBL_DELETE_FILE" USING "/input.txt"
           CALL "CBL_DELETE_DIR"  USING "/docs"

           GOBACK
           .
Task: Delete a file






PHP: <?php
unlink('input.txt');
unlink('/input.txt');
rmdir('docs');
rmdir('/docs');
?>
Task: Delete a file






PHP: <?php
unlink('input.txt');
unlink('/input.txt');
rmdir('docs');
rmdir('/docs');
?>






Ada: with Ada.Directories;  use Ada.Directories;
Task: Delete a file






PHP: <?php
unlink('input.txt');
unlink('/input.txt');
rmdir('docs');
rmdir('/docs');
?>




COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Delete-Files.

       PROCEDURE DIVISION.
           CALL "CBL_DELETE_FILE" USING "input.txt"
           CALL "CBL_DELETE_DIR"  USING "docs"
           CALL "CBL_DELETE_FILE" USING "/input.txt"
           CALL "CBL_DELETE_DIR"  USING "/docs"

           GOBACK
           .
Task: Sum of a series



C#: class Program
{
    static void Main(string[] args)
    {
        

        List<double> myList = new List<double>();
        for (double i = 1; i < 1001; i++)
        {
            myList.Add(i);
        }
        

        var sum = myList.Sum(x => 1/(x*x));

        Console.WriteLine(sum);
        Console.ReadLine();
    }
}









Ada: with Ada.Text_Io; use Ada.Text_Io;

procedure Sum_Series is
   function F(X : Long_Float) return Long_Float is
   begin
      return 1.0 / X**2;
   end F;
   package Lf_Io is new Ada.Text_Io.Float_Io(Long_Float);
   use Lf_Io;
   Sum : Long_Float := 0.0;
   subtype Param_Range is Integer range 1..1000;
begin
   for I in Param_Range loop
      Sum := Sum + F(Long_Float(I));
   end loop;
   Put("Sum of F(x) from" & Integer'Image(Param_Range'First) &
      " to" & Integer'Image(Param_Range'Last) & " is ");
   Put(Item => Sum, Aft => 10, Exp => 0);
   New_Line;
end Sum_Series;
Task: Sum of a series

C: #include <stdio.h>

double Invsqr(double n)
{
	return 1 / (n*n);
}

int main (int argc, char *argv[])
{
	int i, start = 1, end = 1000;
	double sum = 0.0;
	
	for( i = start; i <= end; i++)
		sum += Invsqr((double)i);           
	
	printf("%16.14f\n", sum);
	
	return 0;
}











Ada: with Ada.Text_Io; use Ada.Text_Io;

procedure Sum_Series is
   function F(X : Long_Float) return Long_Float is
   begin
      return 1.0 / X**2;
   end F;
   package Lf_Io is new Ada.Text_Io.Float_Io(Long_Float);
   use Lf_Io;
   Sum : Long_Float := 0.0;
   subtype Param_Range is Integer range 1..1000;
begin
   for I in Param_Range loop
      Sum := Sum + F(Long_Float(I));
   end loop;
   Put("Sum of F(x) from" & Integer'Image(Param_Range'First) &
      " to" & Integer'Image(Param_Range'Last) & " is ");
   Put(Item => Sum, Aft => 10, Exp => 0);
   New_Line;
end Sum_Series;
Task: Sum of a series


C++: #include <iostream>

double f(double x);

int main()
{
    unsigned int start = 1;
    unsigned int end = 1000;
    double sum = 0;

    for( unsigned int x = start; x <= end; ++x )
    {
        sum += f(x);
    }
    std::cout << "Sum of f(x) from " << start << " to " << end << " is " << sum << std::endl;
    return 0;
}


double f(double x)
{
    return ( 1.0 / ( x * x ) );
}










Ada: with Ada.Text_Io; use Ada.Text_Io;

procedure Sum_Series is
   function F(X : Long_Float) return Long_Float is
   begin
      return 1.0 / X**2;
   end F;
   package Lf_Io is new Ada.Text_Io.Float_Io(Long_Float);
   use Lf_Io;
   Sum : Long_Float := 0.0;
   subtype Param_Range is Integer range 1..1000;
begin
   for I in Param_Range loop
      Sum := Sum + F(Long_Float(I));
   end loop;
   Put("Sum of F(x) from" & Integer'Image(Param_Range'First) &
      " to" & Integer'Image(Param_Range'Last) & " is ");
   Put(Item => Sum, Aft => 10, Exp => 0);
   New_Line;
end Sum_Series;
Task: Sum of a series




Go: package main

import ("fmt"; "math")

func main() {
    fmt.Println("known:   ", math.Pi*math.Pi/6)
    sum := 0.
    for i := 1e3; i > 0; i-- {
        sum += 1 / (i * i)
    }
    fmt.Println("computed:", sum)
}








Ada: with Ada.Text_Io; use Ada.Text_Io;

procedure Sum_Series is
   function F(X : Long_Float) return Long_Float is
   begin
      return 1.0 / X**2;
   end F;
   package Lf_Io is new Ada.Text_Io.Float_Io(Long_Float);
   use Lf_Io;
   Sum : Long_Float := 0.0;
   subtype Param_Range is Integer range 1..1000;
begin
   for I in Param_Range loop
      Sum := Sum + F(Long_Float(I));
   end loop;
   Put("Sum of F(x) from" & Integer'Image(Param_Range'First) &
      " to" & Integer'Image(Param_Range'Last) & " is ");
   Put(Item => Sum, Aft => 10, Exp => 0);
   New_Line;
end Sum_Series;