kazuyamaa/multi-language-messages-01 huggingface dataset:
Task: Minimum positive multiple in base 10 using only 0 and 1
Python: def getA004290(n):
    if n < 2:
        return 1
    arr = [[0 for _ in range(n)] for _ in range(n)]
    arr[0][0] = 1
    arr[0][1] = 1
    m = 0
    while True:
        m += 1
        if arr[m - 1][-10 ** m % n] == 1:
            break
        arr[m][0] = 1
        for k in range(1, n):
            arr[m][k] = max([arr[m - 1][k], arr[m - 1][k - 10 ** m % n]])
    r = 10 ** m
    k = -r % n
    for j in range((m - 1), 0, -1):
        if arr[j - 1][k] == 0:
            r = r + 10 ** j
            k = (k - 10 ** j) % n   
    if k == 1:
        r += 1
    return r
 
for n in [i for i in range(1, 11)] + \
          [i for i in range(95, 106)] + \
          [297, 576, 594, 891, 909, 999, 1998, 2079, 2251, 2277, 2439, 2997, 4878]:
    result = getA004290(n)
    print(f"A004290({n}) = {result} = {n} * {result // n})")

VB: Imports System, System.Linq, System.Collections.Generic, System.Console

Module Module1

    Dim fmt As String = "{0,4} * {1,31:n0} = {2,-28}" & vbLf

    Sub B10(ByVal n As Integer)
        If n <= 1 Then Return
        Dim pow As Integer() = New Integer(n) {},
            val As Integer() = New Integer(n) {},
            count As Integer = 0, ten As Integer = 1, x As Integer = 1
        While x <= n : val(x) = ten : For j As Integer = 0 To n
                If pow(j) <> 0 AndAlso pow((j + ten) Mod n) = 0 AndAlso _
                   pow(j) <> x Then pow((j + ten) Mod n) = x
            Next : If pow(ten) = 0 Then pow(ten) = x
            ten = (10 * ten) Mod n : If pow(0) <> 0 Then
                x = n : Dim s As String = "" : While x <> 0
                    Dim p As Integer = pow(x Mod n)
                    If count > p Then s += New String("0"c, count - p)
                    count = p - 1 : s += "1"
                    x = (n + x - val(p)) Mod n : End While
                If count > 0 Then s += New String("0"c, count)
                Write(fmt, n, Decimal.Parse(s) / n, s) : Return
            End If : x += 1 : End While : Write("Can
    End Sub

    Sub Main(ByVal args As String())
        Dim st As DateTime = DateTime.Now
        Dim m As List(Of Integer) = New List(Of Integer) From _
            {297,576,594,891,909,999,1998,2079,2251,2277,2439,2997,4878}
        Write(fmt, "n", "multiplier", "B10")
        WriteLine(New String("-"c, 69)) : Write(fmt, 1, 1, 1)
        For n As Integer = 1 To m.Last()
            If n <= 10 OrElse n >= 95 AndAlso n <= 105 OrElse m.Contains(n) Then B10(n)
        Next : WriteLine(vbLf & "Took {0}ms", (DateTime.Now - st).TotalMilliseconds)
    End Sub
End Module
Task: Mersenne primes
C: #include <stdbool.h>
#include <stdint.h>
#include <stdio.h>

bool isPrime(uint64_t n) {
    uint64_t test;

    if (n < 2) return false;
    if (n % 2 == 0) return n == 2;
    if (n % 3 == 0) return n == 3;

    test = 5;
    while (test * test < n) {
        if (n % test == 0) return false;
        test += 2;
        if (n % test == 0) return false;
        test += 4;
    }

    return true;
}

int main() {
    uint64_t base = 2;
    int pow;

    for (pow = 1; pow <= 32; pow++) {
        if (isPrime(base - 1)) {
            printf("2 ^ %d - 1\n", pow);
        }
        base *= 2;
    }

    return 0;
}

C#: #include <iostream>

bool isPrime(uint64_t n) {
    if (n < 2) return false;
    if (n % 2 == 0) return n == 2;
    if (n % 3 == 0) return n == 3;

    uint64_t test = 5;
    while (test * test < n) {
        if (n % test == 0) return false;
        test += 2;
        if (n % test == 0) return false;
        test += 4;
    }

    return true;
}

int main() {
    uint64_t base = 2;

    for (int pow = 1; pow <= 32; pow++) {
        if (isPrime(base - 1)) {
            std::cout << "2 ^ " << pow << " - 1\n";
        }
        base *= 2;
    }

    return 0;
}
Task: Mersenne primes
C: #include <stdbool.h>
#include <stdint.h>
#include <stdio.h>

bool isPrime(uint64_t n) {
    uint64_t test;

    if (n < 2) return false;
    if (n % 2 == 0) return n == 2;
    if (n % 3 == 0) return n == 3;

    test = 5;
    while (test * test < n) {
        if (n % test == 0) return false;
        test += 2;
        if (n % test == 0) return false;
        test += 4;
    }

    return true;
}

int main() {
    uint64_t base = 2;
    int pow;

    for (pow = 1; pow <= 32; pow++) {
        if (isPrime(base - 1)) {
            printf("2 ^ %d - 1\n", pow);
        }
        base *= 2;
    }

    return 0;
}

C++: #include <iostream>

bool isPrime(uint64_t n) {
    if (n < 2) return false;
    if (n % 2 == 0) return n == 2;
    if (n % 3 == 0) return n == 3;

    uint64_t test = 5;
    while (test * test < n) {
        if (n % test == 0) return false;
        test += 2;
        if (n % test == 0) return false;
        test += 4;
    }

    return true;
}

int main() {
    uint64_t base = 2;

    for (int pow = 1; pow <= 32; pow++) {
        if (isPrime(base - 1)) {
            std::cout << "2 ^ " << pow << " - 1\n";
        }
        base *= 2;
    }

    return 0;
}
Task: Mersenne primes
C: #include <stdbool.h>
#include <stdint.h>
#include <stdio.h>

bool isPrime(uint64_t n) {
    uint64_t test;

    if (n < 2) return false;
    if (n % 2 == 0) return n == 2;
    if (n % 3 == 0) return n == 3;

    test = 5;
    while (test * test < n) {
        if (n % test == 0) return false;
        test += 2;
        if (n % test == 0) return false;
        test += 4;
    }

    return true;
}

int main() {
    uint64_t base = 2;
    int pow;

    for (pow = 1; pow <= 32; pow++) {
        if (isPrime(base - 1)) {
            printf("2 ^ %d - 1\n", pow);
        }
        base *= 2;
    }

    return 0;
}

Go: package main

import (
	"fmt"
	"time"

	
	"math/big"
	
)

func main() {
	start := time.Now()
	one := big.NewInt(1)
	mp := big.NewInt(0)
	bp := big.NewInt(0)
	const max = 22
	for count, p := 0, uint(2); count < max; {
		mp.Lsh(one, p)
		mp.Sub(mp, one)
		if mp.ProbablyPrime(0) {
			elapsed := time.Since(start).Seconds()
			if elapsed >= 0.01 {
				fmt.Printf("2 ^ %-4d - 1 took %6.2f secs\n", p, elapsed)
			} else {
				fmt.Printf("2 ^ %-4d - 1\n", p)
			}
			count++
		}
		for {
			if p > 2 {
				p += 2
			} else {
				p = 3
			}
			bp.SetUint64(uint64(p))
			if bp.ProbablyPrime(0) {
				break
			}
		}
	}
}
Task: Mersenne primes
C: #include <stdbool.h>
#include <stdint.h>
#include <stdio.h>

bool isPrime(uint64_t n) {
    uint64_t test;

    if (n < 2) return false;
    if (n % 2 == 0) return n == 2;
    if (n % 3 == 0) return n == 3;

    test = 5;
    while (test * test < n) {
        if (n % test == 0) return false;
        test += 2;
        if (n % test == 0) return false;
        test += 4;
    }

    return true;
}

int main() {
    uint64_t base = 2;
    int pow;

    for (pow = 1; pow <= 32; pow++) {
        if (isPrime(base - 1)) {
            printf("2 ^ %d - 1\n", pow);
        }
        base *= 2;
    }

    return 0;
}

Java: import java.math.BigInteger;

public class MersennePrimes {
    private static final int MAX = 20;

    private static final BigInteger ONE = BigInteger.ONE;
    private static final BigInteger TWO = BigInteger.valueOf(2);

    private static boolean isPrime(int n) {
        if (n < 2) return false;
        if (n % 2 == 0) return n == 2;
        if (n % 3 == 0) return n == 3;
        int d = 5;
        while (d * d <= n) {
            if (n % d == 0) return false;
            d += 2;
            if (n % d == 0) return false;
            d += 4;
        }
        return true;
    }

    public static void main(String[] args) {
        int count = 0;
        int p = 2;
        while (true) {
            BigInteger m = TWO.shiftLeft(p - 1).subtract(ONE);
            if (m.isProbablePrime(10)) {
                System.out.printf("2 ^ %d - 1\n", p);
                if (++count == MAX) break;
            }
            
            do {
                p = (p > 2) ? p + 2 : 3;
            } while (!isPrime(p));
        }
    }
}
Task: Mersenne primes
C: #include <stdbool.h>
#include <stdint.h>
#include <stdio.h>

bool isPrime(uint64_t n) {
    uint64_t test;

    if (n < 2) return false;
    if (n % 2 == 0) return n == 2;
    if (n % 3 == 0) return n == 3;

    test = 5;
    while (test * test < n) {
        if (n % test == 0) return false;
        test += 2;
        if (n % test == 0) return false;
        test += 4;
    }

    return true;
}

int main() {
    uint64_t base = 2;
    int pow;

    for (pow = 1; pow <= 32; pow++) {
        if (isPrime(base - 1)) {
            printf("2 ^ %d - 1\n", pow);
        }
        base *= 2;
    }

    return 0;
}

Python: import random


def MillerRabinPrimalityTest(number):
    
    if number == 2:
        return True
    elif number == 1 or number % 2 == 0:
        return False
    
    
    
    
    oddPartOfNumber = number - 1
    
    
    timesTwoDividNumber = 0
    
    
    while oddPartOfNumber % 2 == 0:
        oddPartOfNumber = oddPartOfNumber / 2
        timesTwoDividNumber = timesTwoDividNumber + 1 
     
    
    for time in range(3):
        
        
        while True:
            
            randomNumber = random.randint(2, number)-1
            if randomNumber != 0 and randomNumber != 1:
                break
        
        
        randomNumberWithPower = pow(randomNumber, oddPartOfNumber, number)
        
        
        if (randomNumberWithPower != 1) and (randomNumberWithPower != number - 1):
            
            iterationNumber = 1
            
            
            while (iterationNumber <= timesTwoDividNumber - 1) and (randomNumberWithPower != number - 1):
                
                randomNumberWithPower = pow(randomNumberWithPower, 2, number)
                
                
                iterationNumber = iterationNumber + 1
            
            if (randomNumberWithPower != (number - 1)):
                return False
            
    
    return True


MAX = 20
p = 2
count = 0
while True:
    m = (2 << (p - 1)) - 1
    if MillerRabinPrimalityTest(m):
        print "2 ^ {} - 1".format(p)
        count = count + 1
        if count == MAX:
            break
    
    while True:
        p = p + 2 if (p > 2) else 3
        if MillerRabinPrimalityTest(p):
            break
print "done"
Task: Mersenne primes
C: #include <stdbool.h>
#include <stdint.h>
#include <stdio.h>

bool isPrime(uint64_t n) {
    uint64_t test;

    if (n < 2) return false;
    if (n % 2 == 0) return n == 2;
    if (n % 3 == 0) return n == 3;

    test = 5;
    while (test * test < n) {
        if (n % test == 0) return false;
        test += 2;
        if (n % test == 0) return false;
        test += 4;
    }

    return true;
}

int main() {
    uint64_t base = 2;
    int pow;

    for (pow = 1; pow <= 32; pow++) {
        if (isPrime(base - 1)) {
            printf("2 ^ %d - 1\n", pow);
        }
        base *= 2;
    }

    return 0;
}

VB: Imports System.Numerics

Module Module1

    Function Sqrt(x As BigInteger) As BigInteger
        If x < 0 Then
            Throw New ArgumentException("Negative argument.")
        End If
        If x < 2 Then
            Return x
        End If
        Dim y = x / 2
        While y > (x / y)
            y = ((x / y) + y) / 2
        End While
        Return y
    End Function

    Function IsPrime(bi As BigInteger) As Boolean
        If bi < 2 Then
            Return False
        End If
        If bi Mod 2 = 0 Then
            Return bi = 2
        End If
        If bi Mod 3 = 0 Then
            Return bi = 3
        End If
        If bi Mod 5 = 0 Then
            Return bi = 5
        End If
        If bi Mod 7 = 0 Then
            Return bi = 7
        End If
        If bi Mod 11 = 0 Then
            Return bi = 11
        End If
        If bi Mod 13 = 0 Then
            Return bi = 13
        End If
        If bi Mod 17 = 0 Then
            Return bi = 17
        End If
        If bi Mod 19 = 0 Then
            Return bi = 19
        End If

        Dim limit = Sqrt(bi)
        Dim test As BigInteger = 23
        While test < limit
            If bi Mod test = 0 Then
                Return False
            End If
            test += 2
            If bi Mod test = 0 Then
                Return False
            End If
            test += 4
        End While

        Return True
    End Function

    Sub Main()
        Const MAX = 9

        Dim pow = 2
        Dim count = 0

        While True
            If IsPrime(pow) Then
                Dim p = BigInteger.Pow(2, pow) - 1
                If IsPrime(p) Then
                    Console.WriteLine("2 ^ {0} - 1", pow)
                    count += 1
                    If count >= MAX Then
                        Exit While
                    End If
                End If
            End If
            pow += 1
        End While
    End Sub

End Module
Task: Mersenne primes
C#: using System;
using System.Numerics;

namespace MersennePrimes {
    class Program {
        static BigInteger Sqrt(BigInteger x) {
            if (x < 0) throw new ArgumentException("Negative argument.");
            if (x < 2) return x;
            BigInteger y = x / 2;
            while (y > x / y) {
                y = ((x / y) + y) / 2;
            }
            return y;
        }

        static bool IsPrime(BigInteger bi) {
            if (bi < 2) return false;
            if (bi % 2 == 0) return bi == 2;
            if (bi % 3 == 0) return bi == 3;
            if (bi % 5 == 0) return bi == 5;
            if (bi % 7 == 0) return bi == 7;
            if (bi % 11 == 0) return bi == 11;
            if (bi % 13 == 0) return bi == 13;
            if (bi % 17 == 0) return bi == 17;
            if (bi % 19 == 0) return bi == 19;

            BigInteger limit = Sqrt(bi);
            BigInteger test = 23;
            while (test < limit) {
                if (bi % test == 0) return false;
                test += 2;
                if (bi % test == 0) return false;
                test += 4;
            }

            return true;
        }

        static void Main(string[] args) {
            const int MAX = 9;

            int pow = 2;
            int count = 0;

            while (true) {
                if (IsPrime(pow)) {
                    BigInteger p = BigInteger.Pow(2, pow) - 1;
                    if (IsPrime(p)) {
                        Console.WriteLine("2 ^ {0} - 1", pow);
                        if (++count >= MAX) {
                            break;
                        }
                    }
                }
                pow++;
            }
        }
    }
}

C++: #include <iostream>

bool isPrime(uint64_t n) {
    if (n < 2) return false;
    if (n % 2 == 0) return n == 2;
    if (n % 3 == 0) return n == 3;

    uint64_t test = 5;
    while (test * test < n) {
        if (n % test == 0) return false;
        test += 2;
        if (n % test == 0) return false;
        test += 4;
    }

    return true;
}

int main() {
    uint64_t base = 2;

    for (int pow = 1; pow <= 32; pow++) {
        if (isPrime(base - 1)) {
            std::cout << "2 ^ " << pow << " - 1\n";
        }
        base *= 2;
    }

    return 0;
}
Task: Mersenne primes
C++: #include <iostream>

bool isPrime(uint64_t n) {
    if (n < 2) return false;
    if (n % 2 == 0) return n == 2;
    if (n % 3 == 0) return n == 3;

    uint64_t test = 5;
    while (test * test < n) {
        if (n % test == 0) return false;
        test += 2;
        if (n % test == 0) return false;
        test += 4;
    }

    return true;
}

int main() {
    uint64_t base = 2;

    for (int pow = 1; pow <= 32; pow++) {
        if (isPrime(base - 1)) {
            std::cout << "2 ^ " << pow << " - 1\n";
        }
        base *= 2;
    }

    return 0;
}

Go: package main

import (
	"fmt"
	"time"

	
	"math/big"
	
)

func main() {
	start := time.Now()
	one := big.NewInt(1)
	mp := big.NewInt(0)
	bp := big.NewInt(0)
	const max = 22
	for count, p := 0, uint(2); count < max; {
		mp.Lsh(one, p)
		mp.Sub(mp, one)
		if mp.ProbablyPrime(0) {
			elapsed := time.Since(start).Seconds()
			if elapsed >= 0.01 {
				fmt.Printf("2 ^ %-4d - 1 took %6.2f secs\n", p, elapsed)
			} else {
				fmt.Printf("2 ^ %-4d - 1\n", p)
			}
			count++
		}
		for {
			if p > 2 {
				p += 2
			} else {
				p = 3
			}
			bp.SetUint64(uint64(p))
			if bp.ProbablyPrime(0) {
				break
			}
		}
	}
}
Task: Mersenne primes
C++: #include <iostream>

bool isPrime(uint64_t n) {
    if (n < 2) return false;
    if (n % 2 == 0) return n == 2;
    if (n % 3 == 0) return n == 3;

    uint64_t test = 5;
    while (test * test < n) {
        if (n % test == 0) return false;
        test += 2;
        if (n % test == 0) return false;
        test += 4;
    }

    return true;
}

int main() {
    uint64_t base = 2;

    for (int pow = 1; pow <= 32; pow++) {
        if (isPrime(base - 1)) {
            std::cout << "2 ^ " << pow << " - 1\n";
        }
        base *= 2;
    }

    return 0;
}

Java: import java.math.BigInteger;

public class MersennePrimes {
    private static final int MAX = 20;

    private static final BigInteger ONE = BigInteger.ONE;
    private static final BigInteger TWO = BigInteger.valueOf(2);

    private static boolean isPrime(int n) {
        if (n < 2) return false;
        if (n % 2 == 0) return n == 2;
        if (n % 3 == 0) return n == 3;
        int d = 5;
        while (d * d <= n) {
            if (n % d == 0) return false;
            d += 2;
            if (n % d == 0) return false;
            d += 4;
        }
        return true;
    }

    public static void main(String[] args) {
        int count = 0;
        int p = 2;
        while (true) {
            BigInteger m = TWO.shiftLeft(p - 1).subtract(ONE);
            if (m.isProbablePrime(10)) {
                System.out.printf("2 ^ %d - 1\n", p);
                if (++count == MAX) break;
            }
            
            do {
                p = (p > 2) ? p + 2 : 3;
            } while (!isPrime(p));
        }
    }
}
Task: Mersenne primes
C++: #include <iostream>

bool isPrime(uint64_t n) {
    if (n < 2) return false;
    if (n % 2 == 0) return n == 2;
    if (n % 3 == 0) return n == 3;

    uint64_t test = 5;
    while (test * test < n) {
        if (n % test == 0) return false;
        test += 2;
        if (n % test == 0) return false;
        test += 4;
    }

    return true;
}

int main() {
    uint64_t base = 2;

    for (int pow = 1; pow <= 32; pow++) {
        if (isPrime(base - 1)) {
            std::cout << "2 ^ " << pow << " - 1\n";
        }
        base *= 2;
    }

    return 0;
}

Python: import random


def MillerRabinPrimalityTest(number):
    
    if number == 2:
        return True
    elif number == 1 or number % 2 == 0:
        return False
    
    
    
    
    oddPartOfNumber = number - 1
    
    
    timesTwoDividNumber = 0
    
    
    while oddPartOfNumber % 2 == 0:
        oddPartOfNumber = oddPartOfNumber / 2
        timesTwoDividNumber = timesTwoDividNumber + 1 
     
    
    for time in range(3):
        
        
        while True:
            
            randomNumber = random.randint(2, number)-1
            if randomNumber != 0 and randomNumber != 1:
                break
        
        
        randomNumberWithPower = pow(randomNumber, oddPartOfNumber, number)
        
        
        if (randomNumberWithPower != 1) and (randomNumberWithPower != number - 1):
            
            iterationNumber = 1
            
            
            while (iterationNumber <= timesTwoDividNumber - 1) and (randomNumberWithPower != number - 1):
                
                randomNumberWithPower = pow(randomNumberWithPower, 2, number)
                
                
                iterationNumber = iterationNumber + 1
            
            if (randomNumberWithPower != (number - 1)):
                return False
            
    
    return True


MAX = 20
p = 2
count = 0
while True:
    m = (2 << (p - 1)) - 1
    if MillerRabinPrimalityTest(m):
        print "2 ^ {} - 1".format(p)
        count = count + 1
        if count == MAX:
            break
    
    while True:
        p = p + 2 if (p > 2) else 3
        if MillerRabinPrimalityTest(p):
            break
print "done"
Task: Mersenne primes
C++: #include <iostream>

bool isPrime(uint64_t n) {
    if (n < 2) return false;
    if (n % 2 == 0) return n == 2;
    if (n % 3 == 0) return n == 3;

    uint64_t test = 5;
    while (test * test < n) {
        if (n % test == 0) return false;
        test += 2;
        if (n % test == 0) return false;
        test += 4;
    }

    return true;
}

int main() {
    uint64_t base = 2;

    for (int pow = 1; pow <= 32; pow++) {
        if (isPrime(base - 1)) {
            std::cout << "2 ^ " << pow << " - 1\n";
        }
        base *= 2;
    }

    return 0;
}

VB: Imports System.Numerics

Module Module1

    Function Sqrt(x As BigInteger) As BigInteger
        If x < 0 Then
            Throw New ArgumentException("Negative argument.")
        End If
        If x < 2 Then
            Return x
        End If
        Dim y = x / 2
        While y > (x / y)
            y = ((x / y) + y) / 2
        End While
        Return y
    End Function

    Function IsPrime(bi As BigInteger) As Boolean
        If bi < 2 Then
            Return False
        End If
        If bi Mod 2 = 0 Then
            Return bi = 2
        End If
        If bi Mod 3 = 0 Then
            Return bi = 3
        End If
        If bi Mod 5 = 0 Then
            Return bi = 5
        End If
        If bi Mod 7 = 0 Then
            Return bi = 7
        End If
        If bi Mod 11 = 0 Then
            Return bi = 11
        End If
        If bi Mod 13 = 0 Then
            Return bi = 13
        End If
        If bi Mod 17 = 0 Then
            Return bi = 17
        End If
        If bi Mod 19 = 0 Then
            Return bi = 19
        End If

        Dim limit = Sqrt(bi)
        Dim test As BigInteger = 23
        While test < limit
            If bi Mod test = 0 Then
                Return False
            End If
            test += 2
            If bi Mod test = 0 Then
                Return False
            End If
            test += 4
        End While

        Return True
    End Function

    Sub Main()
        Const MAX = 9

        Dim pow = 2
        Dim count = 0

        While True
            If IsPrime(pow) Then
                Dim p = BigInteger.Pow(2, pow) - 1
                If IsPrime(p) Then
                    Console.WriteLine("2 ^ {0} - 1", pow)
                    count += 1
                    If count >= MAX Then
                        Exit While
                    End If
                End If
            End If
            pow += 1
        End While
    End Sub

End Module