WeixiangYan/CodeTransOcean huggingface dataset:
Task: Primality by trial division





Java: public static boolean prime(long a){
   if(a == 2){
      return true;
   }else if(a <= 1 || a % 2 == 0){
      return false;
   }
   long max = (long)Math.sqrt(a);
   for(long n= 3; n <= max; n+= 2){
      if(a % n == 0){ return false; }
   }
   return true;
}







Ada: function Is_Prime(Item : Positive) return Boolean is
   Test : Natural;
begin
   if Item = 1 then
      return False;
   elsif Item = 2 then
      return True;
   elsif Item mod 2 = 0 then
      return False;
   else
      Test := 3;
      while Test <= Integer(Sqrt(Float(Item))) loop
         if Item mod Test = 0 then
            return False;
         end if;
         Test := Test + 2;
      end loop;
   end if;
   return True;
end Is_Prime;
Task: Primality by trial division







Python: def prime(a):
    return not (a < 2 or any(a % x == 0 for x in xrange(2, int(a**0.5) + 1)))





Ada: function Is_Prime(Item : Positive) return Boolean is
   Test : Natural;
begin
   if Item = 1 then
      return False;
   elsif Item = 2 then
      return True;
   elsif Item mod 2 = 0 then
      return False;
   else
      Test := 3;
      while Test <= Integer(Sqrt(Float(Item))) loop
         if Item mod Test = 0 then
            return False;
         end if;
         Test := Test + 2;
      end loop;
   end if;
   return True;
end Is_Prime;
Task: Primality by trial division








VB: Option Explicit

Sub FirstTwentyPrimes()
Dim count As Integer, i As Long, t(19) As String
   Do
      i = i + 1
      If IsPrime(i) Then
         t(count) = i
         count = count + 1
      End If
   Loop While count <= UBound(t)
   Debug.Print Join(t, ", ")
End Sub

Function IsPrime(Nb As Long) As Boolean
   If Nb = 2 Then
      IsPrime = True
   ElseIf Nb < 2 Or Nb Mod 2 = 0 Then
      Exit Function
   Else
      Dim i As Long
      For i = 3 To Sqr(Nb) Step 2
         If Nb Mod i = 0 Then Exit Function
      Next
      IsPrime = True
   End If
End Function




Ada: function Is_Prime(Item : Positive) return Boolean is
   Test : Natural;
begin
   if Item = 1 then
      return False;
   elsif Item = 2 then
      return True;
   elsif Item mod 2 = 0 then
      return False;
   else
      Test := 3;
      while Test <= Integer(Sqrt(Float(Item))) loop
         if Item mod Test = 0 then
            return False;
         end if;
         Test := Test + 2;
      end loop;
   end if;
   return True;
end Is_Prime;
Task: Primality by trial division

C: int is_prime(unsigned int n)
{
	unsigned int p;
	if (!(n & 1) || n < 2 ) return n == 2;

	
	for (p = 3; p <= n/p; p += 2)
		if (!(n % p)) return 0;
	return 1;
}
Task: Primality by trial division



C#: static bool isPrime(int n)
        {
            if (n <= 1) return false;
            for (int i = 2; i * i <= n; i++)            
                if (n % i == 0) return false;            
            return true;
        }
Task: Primality by trial division


C++: #include <cmath>

bool is_prime(unsigned int n)
{
    if (n <= 1)
        return false;
    if (n == 2)
        return true;
    for (unsigned int i = 2; i <= sqrt(n); ++i)
        if (n % i == 0)
            return false;
    return true;
}
Task: Primality by trial division





Java: public static boolean prime(long a){
   if(a == 2){
      return true;
   }else if(a <= 1 || a % 2 == 0){
      return false;
   }
   long max = (long)Math.sqrt(a);
   for(long n= 3; n <= max; n+= 2){
      if(a % n == 0){ return false; }
   }
   return true;
}
Task: Primality by trial division







Python: def prime(a):
    return not (a < 2 or any(a % x == 0 for x in xrange(2, int(a**0.5) + 1)))
Task: Primality by trial division








VB: Option Explicit

Sub FirstTwentyPrimes()
Dim count As Integer, i As Long, t(19) As String
   Do
      i = i + 1
      If IsPrime(i) Then
         t(count) = i
         count = count + 1
      End If
   Loop While count <= UBound(t)
   Debug.Print Join(t, ", ")
End Sub

Function IsPrime(Nb As Long) As Boolean
   If Nb = 2 Then
      IsPrime = True
   ElseIf Nb < 2 Or Nb Mod 2 = 0 Then
      Exit Function
   Else
      Dim i As Long
      For i = 3 To Sqr(Nb) Step 2
         If Nb Mod i = 0 Then Exit Function
      Next
      IsPrime = True
   End If
End Function
Task: Primality by trial division




Go: func IsPrime(n int) bool {
	if n < 0 { n = -n }
	switch {
        case n == 2:
		return true
	case n < 2 || n % 2 == 0:
		return false
	
	default:
		for i = 3; i*i <= n; i += 2 {
			if n % i == 0 { return false }
		}
	}
	return true
}
Task: Primality by trial division



C#: static bool isPrime(int n)
        {
            if (n <= 1) return false;
            for (int i = 2; i * i <= n; i++)            
                if (n % i == 0) return false;            
            return true;
        }








Fortran:  FUNCTION isPrime(number)
   LOGICAL :: isPrime
   INTEGER, INTENT(IN) :: number
   INTEGER :: i
 
   IF(number==2) THEN
      isPrime = .TRUE.
   ELSE IF(number < 2 .OR. MOD(number,2) == 0) THEN
      isPRIME = .FALSE.
   ELSE
      isPrime = .TRUE.
      DO i = 3, INT(SQRT(REAL(number))), 2
         IF(MOD(number,i) == 0) THEN
            isPrime = .FALSE.
            EXIT
         END IF
      END DO
   END IF
 END FUNCTION
Task: Primality by trial division


C++: #include <cmath>

bool is_prime(unsigned int n)
{
    if (n <= 1)
        return false;
    if (n == 2)
        return true;
    for (unsigned int i = 2; i <= sqrt(n); ++i)
        if (n % i == 0)
            return false;
    return true;
}









Fortran:  FUNCTION isPrime(number)
   LOGICAL :: isPrime
   INTEGER, INTENT(IN) :: number
   INTEGER :: i
 
   IF(number==2) THEN
      isPrime = .TRUE.
   ELSE IF(number < 2 .OR. MOD(number,2) == 0) THEN
      isPRIME = .FALSE.
   ELSE
      isPrime = .TRUE.
      DO i = 3, INT(SQRT(REAL(number))), 2
         IF(MOD(number,i) == 0) THEN
            isPrime = .FALSE.
            EXIT
         END IF
      END DO
   END IF
 END FUNCTION
Task: Primality by trial division

C: int is_prime(unsigned int n)
{
	unsigned int p;
	if (!(n & 1) || n < 2 ) return n == 2;

	
	for (p = 3; p <= n/p; p += 2)
		if (!(n % p)) return 0;
	return 1;
}










Fortran:  FUNCTION isPrime(number)
   LOGICAL :: isPrime
   INTEGER, INTENT(IN) :: number
   INTEGER :: i
 
   IF(number==2) THEN
      isPrime = .TRUE.
   ELSE IF(number < 2 .OR. MOD(number,2) == 0) THEN
      isPRIME = .FALSE.
   ELSE
      isPrime = .TRUE.
      DO i = 3, INT(SQRT(REAL(number))), 2
         IF(MOD(number,i) == 0) THEN
            isPrime = .FALSE.
            EXIT
         END IF
      END DO
   END IF
 END FUNCTION
Task: Primality by trial division





Java: public static boolean prime(long a){
   if(a == 2){
      return true;
   }else if(a <= 1 || a % 2 == 0){
      return false;
   }
   long max = (long)Math.sqrt(a);
   for(long n= 3; n <= max; n+= 2){
      if(a % n == 0){ return false; }
   }
   return true;
}






Fortran:  FUNCTION isPrime(number)
   LOGICAL :: isPrime
   INTEGER, INTENT(IN) :: number
   INTEGER :: i
 
   IF(number==2) THEN
      isPrime = .TRUE.
   ELSE IF(number < 2 .OR. MOD(number,2) == 0) THEN
      isPRIME = .FALSE.
   ELSE
      isPrime = .TRUE.
      DO i = 3, INT(SQRT(REAL(number))), 2
         IF(MOD(number,i) == 0) THEN
            isPrime = .FALSE.
            EXIT
         END IF
      END DO
   END IF
 END FUNCTION
Task: Primality by trial division







Python: def prime(a):
    return not (a < 2 or any(a % x == 0 for x in xrange(2, int(a**0.5) + 1)))




Fortran:  FUNCTION isPrime(number)
   LOGICAL :: isPrime
   INTEGER, INTENT(IN) :: number
   INTEGER :: i
 
   IF(number==2) THEN
      isPrime = .TRUE.
   ELSE IF(number < 2 .OR. MOD(number,2) == 0) THEN
      isPRIME = .FALSE.
   ELSE
      isPrime = .TRUE.
      DO i = 3, INT(SQRT(REAL(number))), 2
         IF(MOD(number,i) == 0) THEN
            isPrime = .FALSE.
            EXIT
         END IF
      END DO
   END IF
 END FUNCTION
Task: Primality by trial division








VB: Option Explicit

Sub FirstTwentyPrimes()
Dim count As Integer, i As Long, t(19) As String
   Do
      i = i + 1
      If IsPrime(i) Then
         t(count) = i
         count = count + 1
      End If
   Loop While count <= UBound(t)
   Debug.Print Join(t, ", ")
End Sub

Function IsPrime(Nb As Long) As Boolean
   If Nb = 2 Then
      IsPrime = True
   ElseIf Nb < 2 Or Nb Mod 2 = 0 Then
      Exit Function
   Else
      Dim i As Long
      For i = 3 To Sqr(Nb) Step 2
         If Nb Mod i = 0 Then Exit Function
      Next
      IsPrime = True
   End If
End Function



Fortran:  FUNCTION isPrime(number)
   LOGICAL :: isPrime
   INTEGER, INTENT(IN) :: number
   INTEGER :: i
 
   IF(number==2) THEN
      isPrime = .TRUE.
   ELSE IF(number < 2 .OR. MOD(number,2) == 0) THEN
      isPRIME = .FALSE.
   ELSE
      isPrime = .TRUE.
      DO i = 3, INT(SQRT(REAL(number))), 2
         IF(MOD(number,i) == 0) THEN
            isPrime = .FALSE.
            EXIT
         END IF
      END DO
   END IF
 END FUNCTION
Task: Primality by trial division






PHP: <?php
function prime($a) {
  if (($a % 2 == 0 && $a != 2) || $a < 2)
    return false;
  $limit = sqrt($a);
  for ($i = 2; $i <= $limit; $i++)
    if ($a % $i == 0)
      return false;
  return true;
}

foreach (range(1, 100) as $x)
  if (prime($x)) echo "$x\n";

?>





Fortran:  FUNCTION isPrime(number)
   LOGICAL :: isPrime
   INTEGER, INTENT(IN) :: number
   INTEGER :: i
 
   IF(number==2) THEN
      isPrime = .TRUE.
   ELSE IF(number < 2 .OR. MOD(number,2) == 0) THEN
      isPRIME = .FALSE.
   ELSE
      isPrime = .TRUE.
      DO i = 3, INT(SQRT(REAL(number))), 2
         IF(MOD(number,i) == 0) THEN
            isPrime = .FALSE.
            EXIT
         END IF
      END DO
   END IF
 END FUNCTION
Task: Primality by trial division

C: int is_prime(unsigned int n)
{
	unsigned int p;
	if (!(n & 1) || n < 2 ) return n == 2;

	
	for (p = 3; p <= n/p; p += 2)
		if (!(n % p)) return 0;
	return 1;
}









COBOL:        Identification Division.
       Program-Id. Primality-By-Subdiv.

       Data Division.
       Working-Storage Section.
       78  True-Val  Value 0.
       78  False-Val Value 1.

       Local-Storage Section.
       01  lim Pic 9(10).
       01  i   Pic 9(10).

       Linkage Section.
       01  num    Pic 9(10).
       01  result Pic 9.

       Procedure Division Using num result.
       Main.
           If num <= 1
               Move False-Val To result
               Goback
           Else If num = 2
               Move True-Val To result
               Goback
           End-If

           Compute lim = Function Sqrt(num) + 1
           Perform Varying i From 3 By 1 Until lim < i
               If Function Mod(num, i) = 0
                   Move False-Val To result
                   Goback
               End-If
           End-Perform

           Move True-Val To Result

           Goback
           .
Task: Primality by trial division



C#: static bool isPrime(int n)
        {
            if (n <= 1) return false;
            for (int i = 2; i * i <= n; i++)            
                if (n % i == 0) return false;            
            return true;
        }







COBOL:        Identification Division.
       Program-Id. Primality-By-Subdiv.

       Data Division.
       Working-Storage Section.
       78  True-Val  Value 0.
       78  False-Val Value 1.

       Local-Storage Section.
       01  lim Pic 9(10).
       01  i   Pic 9(10).

       Linkage Section.
       01  num    Pic 9(10).
       01  result Pic 9.

       Procedure Division Using num result.
       Main.
           If num <= 1
               Move False-Val To result
               Goback
           Else If num = 2
               Move True-Val To result
               Goback
           End-If

           Compute lim = Function Sqrt(num) + 1
           Perform Varying i From 3 By 1 Until lim < i
               If Function Mod(num, i) = 0
                   Move False-Val To result
                   Goback
               End-If
           End-Perform

           Move True-Val To Result

           Goback
           .
Task: Primality by trial division


C++: #include <cmath>

bool is_prime(unsigned int n)
{
    if (n <= 1)
        return false;
    if (n == 2)
        return true;
    for (unsigned int i = 2; i <= sqrt(n); ++i)
        if (n % i == 0)
            return false;
    return true;
}








COBOL:        Identification Division.
       Program-Id. Primality-By-Subdiv.

       Data Division.
       Working-Storage Section.
       78  True-Val  Value 0.
       78  False-Val Value 1.

       Local-Storage Section.
       01  lim Pic 9(10).
       01  i   Pic 9(10).

       Linkage Section.
       01  num    Pic 9(10).
       01  result Pic 9.

       Procedure Division Using num result.
       Main.
           If num <= 1
               Move False-Val To result
               Goback
           Else If num = 2
               Move True-Val To result
               Goback
           End-If

           Compute lim = Function Sqrt(num) + 1
           Perform Varying i From 3 By 1 Until lim < i
               If Function Mod(num, i) = 0
                   Move False-Val To result
                   Goback
               End-If
           End-Perform

           Move True-Val To Result

           Goback
           .
Task: Primality by trial division





Java: public static boolean prime(long a){
   if(a == 2){
      return true;
   }else if(a <= 1 || a % 2 == 0){
      return false;
   }
   long max = (long)Math.sqrt(a);
   for(long n= 3; n <= max; n+= 2){
      if(a % n == 0){ return false; }
   }
   return true;
}





COBOL:        Identification Division.
       Program-Id. Primality-By-Subdiv.

       Data Division.
       Working-Storage Section.
       78  True-Val  Value 0.
       78  False-Val Value 1.

       Local-Storage Section.
       01  lim Pic 9(10).
       01  i   Pic 9(10).

       Linkage Section.
       01  num    Pic 9(10).
       01  result Pic 9.

       Procedure Division Using num result.
       Main.
           If num <= 1
               Move False-Val To result
               Goback
           Else If num = 2
               Move True-Val To result
               Goback
           End-If

           Compute lim = Function Sqrt(num) + 1
           Perform Varying i From 3 By 1 Until lim < i
               If Function Mod(num, i) = 0
                   Move False-Val To result
                   Goback
               End-If
           End-Perform

           Move True-Val To Result

           Goback
           .
Task: Primality by trial division







Python: def prime(a):
    return not (a < 2 or any(a % x == 0 for x in xrange(2, int(a**0.5) + 1)))



COBOL:        Identification Division.
       Program-Id. Primality-By-Subdiv.

       Data Division.
       Working-Storage Section.
       78  True-Val  Value 0.
       78  False-Val Value 1.

       Local-Storage Section.
       01  lim Pic 9(10).
       01  i   Pic 9(10).

       Linkage Section.
       01  num    Pic 9(10).
       01  result Pic 9.

       Procedure Division Using num result.
       Main.
           If num <= 1
               Move False-Val To result
               Goback
           Else If num = 2
               Move True-Val To result
               Goback
           End-If

           Compute lim = Function Sqrt(num) + 1
           Perform Varying i From 3 By 1 Until lim < i
               If Function Mod(num, i) = 0
                   Move False-Val To result
                   Goback
               End-If
           End-Perform

           Move True-Val To Result

           Goback
           .
Task: Primality by trial division








VB: Option Explicit

Sub FirstTwentyPrimes()
Dim count As Integer, i As Long, t(19) As String
   Do
      i = i + 1
      If IsPrime(i) Then
         t(count) = i
         count = count + 1
      End If
   Loop While count <= UBound(t)
   Debug.Print Join(t, ", ")
End Sub

Function IsPrime(Nb As Long) As Boolean
   If Nb = 2 Then
      IsPrime = True
   ElseIf Nb < 2 Or Nb Mod 2 = 0 Then
      Exit Function
   Else
      Dim i As Long
      For i = 3 To Sqr(Nb) Step 2
         If Nb Mod i = 0 Then Exit Function
      Next
      IsPrime = True
   End If
End Function


COBOL:        Identification Division.
       Program-Id. Primality-By-Subdiv.

       Data Division.
       Working-Storage Section.
       78  True-Val  Value 0.
       78  False-Val Value 1.

       Local-Storage Section.
       01  lim Pic 9(10).
       01  i   Pic 9(10).

       Linkage Section.
       01  num    Pic 9(10).
       01  result Pic 9.

       Procedure Division Using num result.
       Main.
           If num <= 1
               Move False-Val To result
               Goback
           Else If num = 2
               Move True-Val To result
               Goback
           End-If

           Compute lim = Function Sqrt(num) + 1
           Perform Varying i From 3 By 1 Until lim < i
               If Function Mod(num, i) = 0
                   Move False-Val To result
                   Goback
               End-If
           End-Perform

           Move True-Val To Result

           Goback
           .
Task: Primality by trial division




Go: func IsPrime(n int) bool {
	if n < 0 { n = -n }
	switch {
        case n == 2:
		return true
	case n < 2 || n % 2 == 0:
		return false
	
	default:
		for i = 3; i*i <= n; i += 2 {
			if n % i == 0 { return false }
		}
	}
	return true
}






COBOL:        Identification Division.
       Program-Id. Primality-By-Subdiv.

       Data Division.
       Working-Storage Section.
       78  True-Val  Value 0.
       78  False-Val Value 1.

       Local-Storage Section.
       01  lim Pic 9(10).
       01  i   Pic 9(10).

       Linkage Section.
       01  num    Pic 9(10).
       01  result Pic 9.

       Procedure Division Using num result.
       Main.
           If num <= 1
               Move False-Val To result
               Goback
           Else If num = 2
               Move True-Val To result
               Goback
           End-If

           Compute lim = Function Sqrt(num) + 1
           Perform Varying i From 3 By 1 Until lim < i
               If Function Mod(num, i) = 0
                   Move False-Val To result
                   Goback
               End-If
           End-Perform

           Move True-Val To Result

           Goback
           .
Task: Primality by trial division






PHP: <?php
function prime($a) {
  if (($a % 2 == 0 && $a != 2) || $a < 2)
    return false;
  $limit = sqrt($a);
  for ($i = 2; $i <= $limit; $i++)
    if ($a % $i == 0)
      return false;
  return true;
}

foreach (range(1, 100) as $x)
  if (prime($x)) echo "$x\n";

?>
Task: Primality by trial division






PHP: <?php
function prime($a) {
  if (($a % 2 == 0 && $a != 2) || $a < 2)
    return false;
  $limit = sqrt($a);
  for ($i = 2; $i <= $limit; $i++)
    if ($a % $i == 0)
      return false;
  return true;
}

foreach (range(1, 100) as $x)
  if (prime($x)) echo "$x\n";

?>






Ada: function Is_Prime(Item : Positive) return Boolean is
   Test : Natural;
begin
   if Item = 1 then
      return False;
   elsif Item = 2 then
      return True;
   elsif Item mod 2 = 0 then
      return False;
   else
      Test := 3;
      while Test <= Integer(Sqrt(Float(Item))) loop
         if Item mod Test = 0 then
            return False;
         end if;
         Test := Test + 2;
      end loop;
   end if;
   return True;
end Is_Prime;
Task: Primality by trial division






PHP: <?php
function prime($a) {
  if (($a % 2 == 0 && $a != 2) || $a < 2)
    return false;
  $limit = sqrt($a);
  for ($i = 2; $i <= $limit; $i++)
    if ($a % $i == 0)
      return false;
  return true;
}

foreach (range(1, 100) as $x)
  if (prime($x)) echo "$x\n";

?>




COBOL:        Identification Division.
       Program-Id. Primality-By-Subdiv.

       Data Division.
       Working-Storage Section.
       78  True-Val  Value 0.
       78  False-Val Value 1.

       Local-Storage Section.
       01  lim Pic 9(10).
       01  i   Pic 9(10).

       Linkage Section.
       01  num    Pic 9(10).
       01  result Pic 9.

       Procedure Division Using num result.
       Main.
           If num <= 1
               Move False-Val To result
               Goback
           Else If num = 2
               Move True-Val To result
               Goback
           End-If

           Compute lim = Function Sqrt(num) + 1
           Perform Varying i From 3 By 1 Until lim < i
               If Function Mod(num, i) = 0
                   Move False-Val To result
                   Goback
               End-If
           End-Perform

           Move True-Val To Result

           Goback
           .
Task: MD5



C#: using System.Text;
using System.Security.Cryptography;

byte[] data = Encoding.ASCII.GetBytes("The quick brown fox jumped over the lazy dog's back");
byte[] hash = MD5.Create().ComputeHash(data);
Console.WriteLine(BitConverter.ToString(hash).Replace("-", "").ToLower());









Ada: with Ada.Text_IO; use Ada.Text_IO;
with GNAT.MD5;

procedure MD5_Digest is
begin
   Put(GNAT.MD5.Digest("Foo bar baz"));
end MD5_Digest;
Task: MD5

C: #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <openssl/md5.h>

const char *string = "The quick brown fox jumped over the lazy dog's back";

int main()
{
  int i;
  unsigned char result[MD5_DIGEST_LENGTH];

  MD5(string, strlen(string), result);

  
  for(i = 0; i < MD5_DIGEST_LENGTH; i++)
    printf("%02x", result[i]);
  printf("\n");

  return EXIT_SUCCESS;
}











Ada: with Ada.Text_IO; use Ada.Text_IO;
with GNAT.MD5;

procedure MD5_Digest is
begin
   Put(GNAT.MD5.Digest("Foo bar baz"));
end MD5_Digest;
Task: MD5


C++: #include <string>
#include <iostream>
#include "Poco/MD5Engine.h"
#include "Poco/DigestStream.h"

using Poco::DigestEngine ;
using Poco::MD5Engine ;
using Poco::DigestOutputStream ;

int main( ) {
   std::string myphrase ( "The quick brown fox jumped over the lazy dog's back" ) ;
   MD5Engine md5 ;
   DigestOutputStream outstr( md5 ) ;
   outstr << myphrase ;
   outstr.flush( ) ; 
   const DigestEngine::Digest& digest = md5.digest( ) ;
   std::cout << myphrase << " as a MD5 digest :\n" << DigestEngine::digestToHex( digest ) 
      << " !" << std::endl ;
   return 0 ;
}










Ada: with Ada.Text_IO; use Ada.Text_IO;
with GNAT.MD5;

procedure MD5_Digest is
begin
   Put(GNAT.MD5.Digest("Foo bar baz"));
end MD5_Digest;
Task: MD5




Go: package main

import (
    "crypto/md5"
    "fmt"
)

func main() {
    for _, p := range [][2]string{
        
        {"d41d8cd98f00b204e9800998ecf8427e", ""},
        {"0cc175b9c0f1b6a831c399e269772661", "a"},
        {"900150983cd24fb0d6963f7d28e17f72", "abc"},
        {"f96b697d7cb7938d525a2f31aaf161d0", "message digest"},
        {"c3fcd3d76192e4007dfb496cca67e13b", "abcdefghijklmnopqrstuvwxyz"},
        {"d174ab98d277d9f5a5611c2c9f419d9f",
            "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"},
        {"57edf4a22be3c955ac49da2e2107b67a", "12345678901234567890" +
            "123456789012345678901234567890123456789012345678901234567890"},
        
        {"e38ca1d920c4b8b8d3946b2c72f01680",
            "The quick brown fox jumped over the lazy dog's back"},
    } {
        validate(p[0], p[1])
    }
}

var h = md5.New()

func validate(check, s string) {
    h.Reset()
    h.Write([]byte(s))
    sum := fmt.Sprintf("%x", h.Sum(nil))
    if sum != check {
        fmt.Println("MD5 fail")
        fmt.Println("  for string,", s)
        fmt.Println("  expected:  ", check)
        fmt.Println("  got:       ", sum)
    }
}








Ada: with Ada.Text_IO; use Ada.Text_IO;
with GNAT.MD5;

procedure MD5_Digest is
begin
   Put(GNAT.MD5.Digest("Foo bar baz"));
end MD5_Digest;