WeixiangYan/CodeTransOcean huggingface dataset:
Task: Generate lower case ASCII alphabet




Go: func loweralpha() string {
	p := make([]byte, 26)
	for i := range p {
		p[i] = 'a' + byte(i)
	}
	return string(p)
}





VB: Option Explicit

Sub Main_Lower_Case_Ascii_Alphabet()
Dim Alpha() As String

    Alpha = Alphabet(97, 122)
    Debug.Print Join(Alpha, ", ")
End Sub

Function Alphabet(FirstAscii As Byte, LastAscii As Byte) As String()
Dim strarrTemp() As String, i&

    ReDim strarrTemp(0 To LastAscii - FirstAscii)
    For i = FirstAscii To LastAscii
        strarrTemp(i - FirstAscii) = Chr(i)
    Next
    Alphabet = strarrTemp
    Erase strarrTemp
End Function
Task: Generate lower case ASCII alphabet

C: #include <stdlib.h>

#define N 26

int main() {
    unsigned char lower[N];

    for (size_t i = 0; i < N; i++) {
        lower[i] = i + 'a';
    }

    return EXIT_SUCCESS;
}




Go: func loweralpha() string {
	p := make([]byte, 26)
	for i := range p {
		p[i] = 'a' + byte(i)
	}
	return string(p)
}
Task: Generate lower case ASCII alphabet




Go: func loweralpha() string {
	p := make([]byte, 26)
	for i := range p {
		p[i] = 'a' + byte(i)
	}
	return string(p)
}




Python: 
from string import ascii_lowercase


lower = [chr(i) for i in range(ord('a'), ord('z') + 1)]
Task: Generate lower case ASCII alphabet







Python: 
from string import ascii_lowercase


lower = [chr(i) for i in range(ord('a'), ord('z') + 1)]


VB: Option Explicit

Sub Main_Lower_Case_Ascii_Alphabet()
Dim Alpha() As String

    Alpha = Alphabet(97, 122)
    Debug.Print Join(Alpha, ", ")
End Sub

Function Alphabet(FirstAscii As Byte, LastAscii As Byte) As String()
Dim strarrTemp() As String, i&

    ReDim strarrTemp(0 To LastAscii - FirstAscii)
    For i = FirstAscii To LastAscii
        strarrTemp(i - FirstAscii) = Chr(i)
    Next
    Alphabet = strarrTemp
    Erase strarrTemp
End Function
Task: Generate lower case ASCII alphabet

C: #include <stdlib.h>

#define N 26

int main() {
    unsigned char lower[N];

    for (size_t i = 0; i < N; i++) {
        lower[i] = i + 'a';
    }

    return EXIT_SUCCESS;
}








VB: Option Explicit

Sub Main_Lower_Case_Ascii_Alphabet()
Dim Alpha() As String

    Alpha = Alphabet(97, 122)
    Debug.Print Join(Alpha, ", ")
End Sub

Function Alphabet(FirstAscii As Byte, LastAscii As Byte) As String()
Dim strarrTemp() As String, i&

    ReDim strarrTemp(0 To LastAscii - FirstAscii)
    For i = FirstAscii To LastAscii
        strarrTemp(i - FirstAscii) = Chr(i)
    Next
    Alphabet = strarrTemp
    Erase strarrTemp
End Function
Task: Generate lower case ASCII alphabet


C++: #include <string>
#include <numeric>

int main() {
    std::string lower(26,' ');

    std::iota(lower.begin(), lower.end(), 'a');
}



Go: func loweralpha() string {
	p := make([]byte, 26)
	for i := range p {
		p[i] = 'a' + byte(i)
	}
	return string(p)
}
Task: Generate lower case ASCII alphabet


C++: #include <string>
#include <numeric>

int main() {
    std::string lower(26,' ');

    std::iota(lower.begin(), lower.end(), 'a');
}







VB: Option Explicit

Sub Main_Lower_Case_Ascii_Alphabet()
Dim Alpha() As String

    Alpha = Alphabet(97, 122)
    Debug.Print Join(Alpha, ", ")
End Sub

Function Alphabet(FirstAscii As Byte, LastAscii As Byte) As String()
Dim strarrTemp() As String, i&

    ReDim strarrTemp(0 To LastAscii - FirstAscii)
    For i = FirstAscii To LastAscii
        strarrTemp(i - FirstAscii) = Chr(i)
    Next
    Alphabet = strarrTemp
    Erase strarrTemp
End Function
Task: Generate lower case ASCII alphabet





Java: public class LowerAscii {

    public static void main(String[] args) {
        StringBuilder sb = new StringBuilder(26);
        for (char ch = 'a'; ch <= 'z'; ch++)
            sb.append(ch);
        System.out.printf("lower ascii: %s, length: %s", sb, sb.length());
    }
}




VB: Option Explicit

Sub Main_Lower_Case_Ascii_Alphabet()
Dim Alpha() As String

    Alpha = Alphabet(97, 122)
    Debug.Print Join(Alpha, ", ")
End Sub

Function Alphabet(FirstAscii As Byte, LastAscii As Byte) As String()
Dim strarrTemp() As String, i&

    ReDim strarrTemp(0 To LastAscii - FirstAscii)
    For i = FirstAscii To LastAscii
        strarrTemp(i - FirstAscii) = Chr(i)
    Next
    Alphabet = strarrTemp
    Erase strarrTemp
End Function
Task: Primes whose sum of digits is 25

C: #include <stdbool.h>
#include <stdio.h>

bool is_prime(int n) {
    int i = 5;

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

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

        if (n % i == 0) {
            return false;
        }
        i += 4;
    }

    return true;
}

int digit_sum(int n) {
    int sum = 0;
    while (n > 0) {
        int rem = n % 10;
        n /= 10;
        sum += rem;
    }
    return sum;
}

int main() {
    int n;

    for (n = 2; n < 5000; n++) {
        if (is_prime(n) && digit_sum(n) == 25) {
            printf("%d ", n);
        }
    }

    return 0;
}



C#: #include <algorithm>
#include <chrono>
#include <iomanip>
#include <iostream>
#include <string>

#include <gmpxx.h>

bool is_probably_prime(const mpz_class& n) {
    return mpz_probab_prime_p(n.get_mpz_t(), 3) != 0;
}

bool is_prime(int n) {
    if (n < 2)
        return false;
    if (n % 2 == 0)
        return n == 2;
    if (n % 3 == 0)
        return n == 3;
    for (int p = 5; p * p <= n; p += 4) {
        if (n % p == 0)
            return false;
        p += 2;
        if (n % p == 0)
            return false;
    }
    return true;
}

int digit_sum(int n) {
    int sum = 0;
    for (; n > 0; n /= 10)
        sum += n % 10;
    return sum;
}

int count_all(const std::string& str, int rem) {
    int count = 0;
    if (rem == 0) {
        switch (str.back()) {
        case '1':
        case '3':
        case '7':
        case '9':
            if (is_probably_prime(mpz_class(str)))
                ++count;
            break;
        default:
            break;
        }
    } else {
        for (int i = 1; i <= std::min(9, rem); ++i)
            count += count_all(str + char('0' + i), rem - i);
    }
    return count;
}

int main() {
    std::cout.imbue(std::locale(""));
    const int limit = 5000;
    std::cout << "Primes < " << limit << " whose digits sum to 25:\n";
    int count = 0;
    for (int p = 1; p < limit; ++p) {
        if (digit_sum(p) == 25 && is_prime(p)) {
            ++count;
            std::cout << std::setw(6) << p << (count % 10 == 0 ? '\n' : ' ');
        }
    }
    std::cout << '\n';

    auto start = std::chrono::steady_clock::now();
    count = count_all("", 25);
    auto end = std::chrono::steady_clock::now();
    std::cout << "\nThere are " << count
              << " primes whose digits sum to 25 and include no zeros.\n";
    std::cout << "Time taken: "
              << std::chrono::duration<double>(end - start).count() << "s\n";
    return 0;
}
Task: Primes whose sum of digits is 25

C: #include <stdbool.h>
#include <stdio.h>

bool is_prime(int n) {
    int i = 5;

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

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

        if (n % i == 0) {
            return false;
        }
        i += 4;
    }

    return true;
}

int digit_sum(int n) {
    int sum = 0;
    while (n > 0) {
        int rem = n % 10;
        n /= 10;
        sum += rem;
    }
    return sum;
}

int main() {
    int n;

    for (n = 2; n < 5000; n++) {
        if (is_prime(n) && digit_sum(n) == 25) {
            printf("%d ", n);
        }
    }

    return 0;
}


C++: #include <algorithm>
#include <chrono>
#include <iomanip>
#include <iostream>
#include <string>

#include <gmpxx.h>

bool is_probably_prime(const mpz_class& n) {
    return mpz_probab_prime_p(n.get_mpz_t(), 3) != 0;
}

bool is_prime(int n) {
    if (n < 2)
        return false;
    if (n % 2 == 0)
        return n == 2;
    if (n % 3 == 0)
        return n == 3;
    for (int p = 5; p * p <= n; p += 4) {
        if (n % p == 0)
            return false;
        p += 2;
        if (n % p == 0)
            return false;
    }
    return true;
}

int digit_sum(int n) {
    int sum = 0;
    for (; n > 0; n /= 10)
        sum += n % 10;
    return sum;
}

int count_all(const std::string& str, int rem) {
    int count = 0;
    if (rem == 0) {
        switch (str.back()) {
        case '1':
        case '3':
        case '7':
        case '9':
            if (is_probably_prime(mpz_class(str)))
                ++count;
            break;
        default:
            break;
        }
    } else {
        for (int i = 1; i <= std::min(9, rem); ++i)
            count += count_all(str + char('0' + i), rem - i);
    }
    return count;
}

int main() {
    std::cout.imbue(std::locale(""));
    const int limit = 5000;
    std::cout << "Primes < " << limit << " whose digits sum to 25:\n";
    int count = 0;
    for (int p = 1; p < limit; ++p) {
        if (digit_sum(p) == 25 && is_prime(p)) {
            ++count;
            std::cout << std::setw(6) << p << (count % 10 == 0 ? '\n' : ' ');
        }
    }
    std::cout << '\n';

    auto start = std::chrono::steady_clock::now();
    count = count_all("", 25);
    auto end = std::chrono::steady_clock::now();
    std::cout << "\nThere are " << count
              << " primes whose digits sum to 25 and include no zeros.\n";
    std::cout << "Time taken: "
              << std::chrono::duration<double>(end - start).count() << "s\n";
    return 0;
}
Task: Primes whose sum of digits is 25

C: #include <stdbool.h>
#include <stdio.h>

bool is_prime(int n) {
    int i = 5;

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

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

        if (n % i == 0) {
            return false;
        }
        i += 4;
    }

    return true;
}

int digit_sum(int n) {
    int sum = 0;
    while (n > 0) {
        int rem = n % 10;
        n /= 10;
        sum += rem;
    }
    return sum;
}

int main() {
    int n;

    for (n = 2; n < 5000; n++) {
        if (is_prime(n) && digit_sum(n) == 25) {
            printf("%d ", n);
        }
    }

    return 0;
}




Go: package main

import (
    "fmt"
    big "github.com/ncw/gmp"
    "time"
)


func sieve(limit int) []bool {
    limit++
    
    c := make([]bool, limit) 
    c[0] = true
    c[1] = true
    
    p := 3 
    for {
        p2 := p * p
        if p2 >= limit {
            break
        }
        for i := p2; i < limit; i += 2 * p {
            c[i] = true
        }
        for {
            p += 2
            if !c[p] {
                break
            }
        }
    }
    return c
}

func sumDigits(n int) int {
    sum := 0
    for n > 0 {
        sum += n % 10
        n /= 10
    }
    return sum
}

func min(a, b int) int {
    if a < b {
        return a
    }
    return b
}


func countAll(p string, rem, res int) int {
    if rem == 0 {
        b := p[len(p)-1]
        if b == '1' || b == '3' || b == '7' || b == '9' {
            z := new(big.Int)
            z.SetString(p, 10)
            if z.ProbablyPrime(1) {
                res++
            }
        }
    } else {
        for i := 1; i <= min(9, rem); i++ {
            res = countAll(p+fmt.Sprintf("%d", i), rem-i, res)
        }
    }
    return res
}

func commatize(n int) string {
    s := fmt.Sprintf("%d", n)
    if n < 0 {
        s = s[1:]
    }
    le := len(s)
    for i := le - 3; i >= 1; i -= 3 {
        s = s[0:i] + "," + s[i:]
    }
    if n >= 0 {
        return s
    }
    return "-" + s
}

func main() {
    start := time.Now()
    c := sieve(4999)
    var primes25 []int
    for i := 997; i < 5000; i += 2 {
        if !c[i] && sumDigits(i) == 25 {
            primes25 = append(primes25, i)
        }
    }
    fmt.Println("The", len(primes25), "primes under 5,000 whose digits sum to 25 are:")
    fmt.Println(primes25)
    n := countAll("", 25, 0)
    fmt.Println("\nThere are", commatize(n), "primes whose digits sum to 25 and include no zeros.")
    fmt.Printf("\nTook %s\n", time.Since(start))
}
Task: Primes whose sum of digits is 25

C: #include <stdbool.h>
#include <stdio.h>

bool is_prime(int n) {
    int i = 5;

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

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

        if (n % i == 0) {
            return false;
        }
        i += 4;
    }

    return true;
}

int digit_sum(int n) {
    int sum = 0;
    while (n > 0) {
        int rem = n % 10;
        n /= 10;
        sum += rem;
    }
    return sum;
}

int main() {
    int n;

    for (n = 2; n < 5000; n++) {
        if (is_prime(n) && digit_sum(n) == 25) {
            printf("%d ", n);
        }
    }

    return 0;
}





Java: import java.math.BigInteger;

public class PrimeSum {
    private static int digitSum(BigInteger bi) {
        int sum = 0;
        while (bi.compareTo(BigInteger.ZERO) > 0) {
            BigInteger[] dr = bi.divideAndRemainder(BigInteger.TEN);
            sum += dr[1].intValue();
            bi = dr[0];
        }
        return sum;
    }

    public static void main(String[] args) {
        BigInteger fiveK = BigInteger.valueOf(5_000);
        BigInteger bi = BigInteger.valueOf(2);
        while (bi.compareTo(fiveK) < 0) {
            if (digitSum(bi) == 25) {
                System.out.print(bi);
                System.out.print("  ");
            }
            bi = bi.nextProbablePrime();
        }
        System.out.println();
    }
}
Task: Primes whose sum of digits is 25

C: #include <stdbool.h>
#include <stdio.h>

bool is_prime(int n) {
    int i = 5;

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

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

        if (n % i == 0) {
            return false;
        }
        i += 4;
    }

    return true;
}

int digit_sum(int n) {
    int sum = 0;
    while (n > 0) {
        int rem = n % 10;
        n /= 10;
        sum += rem;
    }
    return sum;
}

int main() {
    int n;

    for (n = 2; n < 5000; n++) {
        if (is_prime(n) && digit_sum(n) == 25) {
            printf("%d ", n);
        }
    }

    return 0;
}







Python: 

from itertools import takewhile



def primesWithGivenDigitSum(below, n):
    
    return list(
        takewhile(
            lambda x: below > x,
            (
                x for x in primes()
                if n == sum(int(c) for c in str(x))
            )
        )
    )




def main():
    
    matches = primesWithGivenDigitSum(5000, 25)
    print(
        str(len(matches)) + (
            ' primes below 5000 with a decimal digit sum of 25:\n'
        )
    )
    print(
        '\n'.join([
            ' '.join([str(x).rjust(4, ' ') for x in xs])
            for xs in chunksOf(4)(matches)
        ])
    )





def chunksOf(n):
    
    def go(xs):
        return (
            xs[i:n + i] for i in range(0, len(xs), n)
        ) if 0 < n else None
    return go



def primes():
    
    n = 2
    dct = {}
    while True:
        if n in dct:
            for p in dct[n]:
                dct.setdefault(n + p, []).append(p)
            del dct[n]
        else:
            yield n
            dct[n * n] = [n]
        n = 1 + n



if __name__ == '__main__':
    main()
Task: Primes whose sum of digits is 25


C++: #include <algorithm>
#include <chrono>
#include <iomanip>
#include <iostream>
#include <string>

#include <gmpxx.h>

bool is_probably_prime(const mpz_class& n) {
    return mpz_probab_prime_p(n.get_mpz_t(), 3) != 0;
}

bool is_prime(int n) {
    if (n < 2)
        return false;
    if (n % 2 == 0)
        return n == 2;
    if (n % 3 == 0)
        return n == 3;
    for (int p = 5; p * p <= n; p += 4) {
        if (n % p == 0)
            return false;
        p += 2;
        if (n % p == 0)
            return false;
    }
    return true;
}

int digit_sum(int n) {
    int sum = 0;
    for (; n > 0; n /= 10)
        sum += n % 10;
    return sum;
}

int count_all(const std::string& str, int rem) {
    int count = 0;
    if (rem == 0) {
        switch (str.back()) {
        case '1':
        case '3':
        case '7':
        case '9':
            if (is_probably_prime(mpz_class(str)))
                ++count;
            break;
        default:
            break;
        }
    } else {
        for (int i = 1; i <= std::min(9, rem); ++i)
            count += count_all(str + char('0' + i), rem - i);
    }
    return count;
}

int main() {
    std::cout.imbue(std::locale(""));
    const int limit = 5000;
    std::cout << "Primes < " << limit << " whose digits sum to 25:\n";
    int count = 0;
    for (int p = 1; p < limit; ++p) {
        if (digit_sum(p) == 25 && is_prime(p)) {
            ++count;
            std::cout << std::setw(6) << p << (count % 10 == 0 ? '\n' : ' ');
        }
    }
    std::cout << '\n';

    auto start = std::chrono::steady_clock::now();
    count = count_all("", 25);
    auto end = std::chrono::steady_clock::now();
    std::cout << "\nThere are " << count
              << " primes whose digits sum to 25 and include no zeros.\n";
    std::cout << "Time taken: "
              << std::chrono::duration<double>(end - start).count() << "s\n";
    return 0;
}




Java: import java.math.BigInteger;

public class PrimeSum {
    private static int digitSum(BigInteger bi) {
        int sum = 0;
        while (bi.compareTo(BigInteger.ZERO) > 0) {
            BigInteger[] dr = bi.divideAndRemainder(BigInteger.TEN);
            sum += dr[1].intValue();
            bi = dr[0];
        }
        return sum;
    }

    public static void main(String[] args) {
        BigInteger fiveK = BigInteger.valueOf(5_000);
        BigInteger bi = BigInteger.valueOf(2);
        while (bi.compareTo(fiveK) < 0) {
            if (digitSum(bi) == 25) {
                System.out.print(bi);
                System.out.print("  ");
            }
            bi = bi.nextProbablePrime();
        }
        System.out.println();
    }
}
Task: Primes whose sum of digits is 25


C++: #include <algorithm>
#include <chrono>
#include <iomanip>
#include <iostream>
#include <string>

#include <gmpxx.h>

bool is_probably_prime(const mpz_class& n) {
    return mpz_probab_prime_p(n.get_mpz_t(), 3) != 0;
}

bool is_prime(int n) {
    if (n < 2)
        return false;
    if (n % 2 == 0)
        return n == 2;
    if (n % 3 == 0)
        return n == 3;
    for (int p = 5; p * p <= n; p += 4) {
        if (n % p == 0)
            return false;
        p += 2;
        if (n % p == 0)
            return false;
    }
    return true;
}

int digit_sum(int n) {
    int sum = 0;
    for (; n > 0; n /= 10)
        sum += n % 10;
    return sum;
}

int count_all(const std::string& str, int rem) {
    int count = 0;
    if (rem == 0) {
        switch (str.back()) {
        case '1':
        case '3':
        case '7':
        case '9':
            if (is_probably_prime(mpz_class(str)))
                ++count;
            break;
        default:
            break;
        }
    } else {
        for (int i = 1; i <= std::min(9, rem); ++i)
            count += count_all(str + char('0' + i), rem - i);
    }
    return count;
}

int main() {
    std::cout.imbue(std::locale(""));
    const int limit = 5000;
    std::cout << "Primes < " << limit << " whose digits sum to 25:\n";
    int count = 0;
    for (int p = 1; p < limit; ++p) {
        if (digit_sum(p) == 25 && is_prime(p)) {
            ++count;
            std::cout << std::setw(6) << p << (count % 10 == 0 ? '\n' : ' ');
        }
    }
    std::cout << '\n';

    auto start = std::chrono::steady_clock::now();
    count = count_all("", 25);
    auto end = std::chrono::steady_clock::now();
    std::cout << "\nThere are " << count
              << " primes whose digits sum to 25 and include no zeros.\n";
    std::cout << "Time taken: "
              << std::chrono::duration<double>(end - start).count() << "s\n";
    return 0;
}






Python: 

from itertools import takewhile



def primesWithGivenDigitSum(below, n):
    
    return list(
        takewhile(
            lambda x: below > x,
            (
                x for x in primes()
                if n == sum(int(c) for c in str(x))
            )
        )
    )




def main():
    
    matches = primesWithGivenDigitSum(5000, 25)
    print(
        str(len(matches)) + (
            ' primes below 5000 with a decimal digit sum of 25:\n'
        )
    )
    print(
        '\n'.join([
            ' '.join([str(x).rjust(4, ' ') for x in xs])
            for xs in chunksOf(4)(matches)
        ])
    )





def chunksOf(n):
    
    def go(xs):
        return (
            xs[i:n + i] for i in range(0, len(xs), n)
        ) if 0 < n else None
    return go



def primes():
    
    n = 2
    dct = {}
    while True:
        if n in dct:
            for p in dct[n]:
                dct.setdefault(n + p, []).append(p)
            del dct[n]
        else:
            yield n
            dct[n * n] = [n]
        n = 1 + n



if __name__ == '__main__':
    main()
Task: Primes whose sum of digits is 25




Go: package main

import (
    "fmt"
    big "github.com/ncw/gmp"
    "time"
)


func sieve(limit int) []bool {
    limit++
    
    c := make([]bool, limit) 
    c[0] = true
    c[1] = true
    
    p := 3 
    for {
        p2 := p * p
        if p2 >= limit {
            break
        }
        for i := p2; i < limit; i += 2 * p {
            c[i] = true
        }
        for {
            p += 2
            if !c[p] {
                break
            }
        }
    }
    return c
}

func sumDigits(n int) int {
    sum := 0
    for n > 0 {
        sum += n % 10
        n /= 10
    }
    return sum
}

func min(a, b int) int {
    if a < b {
        return a
    }
    return b
}


func countAll(p string, rem, res int) int {
    if rem == 0 {
        b := p[len(p)-1]
        if b == '1' || b == '3' || b == '7' || b == '9' {
            z := new(big.Int)
            z.SetString(p, 10)
            if z.ProbablyPrime(1) {
                res++
            }
        }
    } else {
        for i := 1; i <= min(9, rem); i++ {
            res = countAll(p+fmt.Sprintf("%d", i), rem-i, res)
        }
    }
    return res
}

func commatize(n int) string {
    s := fmt.Sprintf("%d", n)
    if n < 0 {
        s = s[1:]
    }
    le := len(s)
    for i := le - 3; i >= 1; i -= 3 {
        s = s[0:i] + "," + s[i:]
    }
    if n >= 0 {
        return s
    }
    return "-" + s
}

func main() {
    start := time.Now()
    c := sieve(4999)
    var primes25 []int
    for i := 997; i < 5000; i += 2 {
        if !c[i] && sumDigits(i) == 25 {
            primes25 = append(primes25, i)
        }
    }
    fmt.Println("The", len(primes25), "primes under 5,000 whose digits sum to 25 are:")
    fmt.Println(primes25)
    n := countAll("", 25, 0)
    fmt.Println("\nThere are", commatize(n), "primes whose digits sum to 25 and include no zeros.")
    fmt.Printf("\nTook %s\n", time.Since(start))
}


Java: import java.math.BigInteger;

public class PrimeSum {
    private static int digitSum(BigInteger bi) {
        int sum = 0;
        while (bi.compareTo(BigInteger.ZERO) > 0) {
            BigInteger[] dr = bi.divideAndRemainder(BigInteger.TEN);
            sum += dr[1].intValue();
            bi = dr[0];
        }
        return sum;
    }

    public static void main(String[] args) {
        BigInteger fiveK = BigInteger.valueOf(5_000);
        BigInteger bi = BigInteger.valueOf(2);
        while (bi.compareTo(fiveK) < 0) {
            if (digitSum(bi) == 25) {
                System.out.print(bi);
                System.out.print("  ");
            }
            bi = bi.nextProbablePrime();
        }
        System.out.println();
    }
}