WeixiangYan/CodeTransOcean huggingface dataset:
Task: Anaprimes


C++: #include <array>
#include <iostream>
#include <map>
#include <vector>

#include <primesieve.hpp>

using digit_set = std::array<int, 10>;

digit_set get_digits(uint64_t n) {
    digit_set result = {};
    for (; n > 0; n /= 10)
        ++result[n % 10];
    return result;
}

int main() {
    std::cout.imbue(std::locale(""));
    primesieve::iterator pi;
    using map_type =
        std::map<digit_set, std::vector<uint64_t>, std::greater<digit_set>>;
    map_type anaprimes;
    for (uint64_t limit = 1000; limit <= 10000000000;) {
        uint64_t prime = pi.next_prime();
        if (prime > limit) {
            size_t max_length = 0;
            std::vector<map_type::iterator> groups;
            for (auto i = anaprimes.begin(); i != anaprimes.end(); ++i) {
                if (i->second.size() > max_length) {
                    groups.clear();
                    max_length = i->second.size();
                }
                if (max_length == i->second.size())
                    groups.push_back(i);
            }
            std::cout << "Largest group(s) of anaprimes before " << limit
                      << ": " << max_length << " members:\n";
            for (auto i : groups) {
                std::cout << "  First: " << i->second.front()
                          << "  Last: " << i->second.back() << '\n';
            }
            std::cout << '\n';
            anaprimes.clear();
            limit *= 10;
        }
        anaprimes[get_digits(prime)].push_back(prime);
    }
}



Go: package main

import (
    "fmt"
    "rcu"
    "sort"
)

func main() {
    const limit = int(1e10)
    const maxIndex = 9
    primes := rcu.Primes(limit)
    anaprimes := make(map[int][]int)
    for _, p := range primes {
        digs := rcu.Digits(p, 10)
        key := 1
        for _, dig := range digs {
            key *= primes[dig]
        }
        if _, ok := anaprimes[key]; ok {
            anaprimes[key] = append(anaprimes[key], p)
        } else {
            anaprimes[key] = []int{p}
        }
    }
    largest := make([]int, maxIndex+1)
    groups := make([][][]int, maxIndex+1)
    for key := range anaprimes {
        v := anaprimes[key]
        nd := len(rcu.Digits(v[0], 10))
        c := len(v)
        if c > largest[nd-1] {
            largest[nd-1] = c
            groups[nd-1] = [][]int{v}
        } else if c == largest[nd-1] {
            groups[nd-1] = append(groups[nd-1], v)
        }
    }
    j := 1000
    for i := 2; i <= maxIndex; i++ {
        js := rcu.Commatize(j)
        ls := rcu.Commatize(largest[i])
        fmt.Printf("Largest group(s) of anaprimes before %s: %s members:\n", js, ls)
        sort.Slice(groups[i], func(k, l int) bool {
            return groups[i][k][0] < groups[i][l][0]
        })
        for _, g := range groups[i] {
            fmt.Printf("  First: %s  Last: %s\n", rcu.Commatize(g[0]), rcu.Commatize(g[len(g)-1]))
        }
        j *= 10
        fmt.Println()
    }
}
Task: Base 16 numbers needing a to f


C++: #include <iomanip>
#include <iostream>



bool nondecimal(unsigned int n) {
    for (; n > 0; n >>= 4) {
        if ((n & 0xF) > 9)
            return true;
    }
    return false;
}

int main() {
    unsigned int count = 0;
    for (unsigned int n = 0; n < 501; ++n) {
        if (nondecimal(n)) {
            ++count;
            std::cout << std::setw(3) << n << (count % 15 == 0 ? '\n' : ' ');
        }
    }
    std::cout << "\n\n" << count << " such numbers found.\n";
}



Go: package main

import (
    "fmt"
    "strconv"
    "strings"
)

func main() {
    const nondecimal = "abcdef"
    c := 0
    for i := int64(0); i <= 500; i++ {
        hex := strconv.FormatInt(i, 16)
        if strings.ContainsAny(nondecimal, hex) {
            fmt.Printf("%3d ", i)
            c++
            if c%15 == 0 {
                fmt.Println()
            }
        }
    }
    fmt.Printf("\n\n%d such numbers found.\n", c)
}
Task: Fixed length records


C++: #include <algorithm>
#include <cstdlib>
#include <fstream>
#include <iostream>

void reverse(std::istream& in, std::ostream& out) {
    constexpr size_t record_length = 80;
    char record[record_length];
    while (in.read(record, record_length)) {
        std::reverse(std::begin(record), std::end(record));
        out.write(record, record_length);
    }
    out.flush();
}

int main(int argc, char** argv) {
    std::ifstream in("infile.dat", std::ios_base::binary);
    if (!in) {
        std::cerr << "Cannot open input file\n";
        return EXIT_FAILURE;
    }
    std::ofstream out("outfile.dat", std::ios_base::binary);
    if (!out) {
        std::cerr << "Cannot open output file\n";
        return EXIT_FAILURE;
    }
    try {
        in.exceptions(std::ios_base::badbit);
        out.exceptions(std::ios_base::badbit);
        reverse(in, out);
    } catch (const std::exception& ex) {
        std::cerr << "I/O error: " << ex.what() << '\n';
        return EXIT_FAILURE;
    }
    return EXIT_SUCCESS;
}



Go: package main

import (
    "fmt"
    "log"
    "os"
    "os/exec"
)

func reverseBytes(bytes []byte) {
    for i, j := 0, len(bytes)-1; i < j; i, j = i+1, j-1 {
        bytes[i], bytes[j] = bytes[j], bytes[i]
    }
}

func check(err error) {
    if err != nil {
        log.Fatal(err)
    }
}

func main() {
    in, err := os.Open("infile.dat")
    check(err)
    defer in.Close()

    out, err := os.Create("outfile.dat")
    check(err)

    record := make([]byte, 80)
    empty := make([]byte, 80)
    for {
        n, err := in.Read(record)
        if err != nil {
            if n == 0 {
                break 
            } else {
                out.Close()
                log.Fatal(err)
            }
        }
        reverseBytes(record)
        out.Write(record)
        copy(record, empty)
    }
    out.Close()

    
    
    cmd := exec.Command("dd", "if=outfile.dat", "cbs=80", "conv=unblock")
    bytes, err := cmd.Output()
    check(err)
    fmt.Println(string(bytes))
}
Task: Find words whose first and last three letters are equal


C++: #include <cstdlib>
#include <fstream>
#include <iostream>

int main(int argc, char** argv) {
    const char* filename(argc < 2 ? "unixdict.txt" : argv[1]);
    std::ifstream in(filename);
    if (!in) {
        std::cerr << "Cannot open file '" << filename << "'.\n";
        return EXIT_FAILURE;
    }
    std::string word;
    int n = 0;
    while (getline(in, word)) {
        const size_t len = word.size();
        if (len > 5 && word.compare(0, 3, word, len - 3) == 0)
            std::cout << ++n << ": " << word << '\n';
    }
    return EXIT_SUCCESS;
}



Go: package main

import (
    "bytes"
    "fmt"
    "io/ioutil"
    "log"
    "unicode/utf8"
)

func main() {
    wordList := "unixdict.txt"
    b, err := ioutil.ReadFile(wordList)
    if err != nil {
        log.Fatal("Error reading file")
    }
    bwords := bytes.Fields(b)
    count := 0
    for _, bword := range bwords {
        s := string(bword)
        if utf8.RuneCountInString(s) > 5 && (s[0:3] == s[len(s)-3:]) {
            count++
            fmt.Printf("%d: %s\n", count, s)
        }
    }
}
Task: Giuga numbers


C++: #include <iostream>


bool is_giuga(unsigned int n) {
    unsigned int m = n / 2;
    auto test_factor = [&m, n](unsigned int p) -> bool {
        if (m % p != 0)
            return true;
        m /= p;
        return m % p != 0 && (n / p - 1) % p == 0;
    };
    if (!test_factor(3) || !test_factor(5))
        return false;
    static constexpr unsigned int wheel[] = {4, 2, 4, 2, 4, 6, 2, 6};
    for (unsigned int p = 7, i = 0; p * p <= m; ++i) {
        if (!test_factor(p))
            return false;
        p += wheel[i & 7];
    }
    return m == 1 || (n / m - 1) % m == 0;
}

int main() {
    std::cout << "First 5 Giuga numbers:\n";
    
    for (unsigned int i = 0, n = 6; i < 5; n += 4) {
        if (is_giuga(n)) {
            std::cout << n << '\n';
            ++i;
        }
    }
}



Go: package main

import "fmt"

var factors []int
var inc = []int{4, 2, 4, 2, 4, 6, 2, 6}



func primeFactors(n int) {
    factors = factors[:0]
    factors = append(factors, 2)
    last := 2
    n /= 2
    for n%3 == 0 {
        if last == 3 {
            factors = factors[:0]
            return
        }
        last = 3
        factors = append(factors, 3)
        n /= 3
    }
    for n%5 == 0 {
        if last == 5 {
            factors = factors[:0]
            return
        }
        last = 5
        factors = append(factors, 5)
        n /= 5
    }
    for k, i := 7, 0; k*k <= n; {
        if n%k == 0 {
            if last == k {
                factors = factors[:0]
                return
            }
            last = k
            factors = append(factors, k)
            n /= k
        } else {
            k += inc[i]
            i = (i + 1) % 8
        }
    }
    if n > 1 {
        factors = append(factors, n)
    }
}

func main() {
    const limit = 5
    var giuga []int
    
    for n := 6; len(giuga) < limit; n += 4 {
        primeFactors(n)
        
        if len(factors) > 2 {
            isGiuga := true
            for _, f := range factors {
                if (n/f-1)%f != 0 {
                    isGiuga = false
                    break
                }
            }
            if isGiuga {
                giuga = append(giuga, n)
            }
        }
    }
    fmt.Println("The first", limit, "Giuga numbers are:")
    fmt.Println(giuga)
}
Task: Polynomial synthetic division


C++: 

#include <iostream>
#include <vector>
#include <string>
#include <cmath>



std::string frmtPolynomial(std::vector<int> polynomial, bool remainder = false)
{
	std::string r = "";

	if (remainder) 
	{
		r = " r: " + std::to_string(polynomial.back());
		polynomial.pop_back();
	}

	std::string formatted = "";
	
	int degree = polynomial.size() - 1;
	int d = degree;

	for (int i : polynomial)
	{
		if (d < degree)
		{
			if (i >= 0) 
			{
				formatted += " + ";
			}
			else
			{
				formatted += " - ";
			}
		}

		formatted += std::to_string(abs(i));

		if (d > 1)
		{
			formatted += "x^" + std::to_string(d);
		}
		else if (d == 1)
		{
			formatted += "x";
		}

		d--;
	}

	return formatted;
}



std::vector<int> syntheticDiv(std::vector<int> dividend, std::vector<int> divisor)
{
	std::vector<int> quotient;
	quotient = dividend;

	int normalizer = divisor[0];
	
	for (int i = 0; i < dividend.size() - (divisor.size() - 1); i++)
	{
		quotient[i] /= normalizer;
		int coef = quotient[i];

		if (coef != 0) 
		{
			for (int j = 1; j < divisor.size(); j++)
			{
				quotient[i + j] += -divisor[j] * coef;
			}
        }

	}

	return quotient;
}



int main(int argc, char **argv) 
{
	std::vector<int> dividend{ 1, -12, 0, -42};
	std::vector<int> divisor{ 1, -3};

	std::cout << frmtPolynomial(dividend) << "\n";
	std::cout << frmtPolynomial(divisor) << "\n";

	std::vector<int> quotient = syntheticDiv(dividend, divisor);

	std::cout << frmtPolynomial(quotient, true) << "\n";

}



Go: package main

import (
    "fmt"
    "math/big"
)

func div(dividend, divisor []*big.Rat) (quotient, remainder []*big.Rat) {
    out := make([]*big.Rat, len(dividend))
    for i, c := range dividend {
        out[i] = new(big.Rat).Set(c)
    }
    for i := 0; i < len(dividend)-(len(divisor)-1); i++ {
        out[i].Quo(out[i], divisor[0])
        if coef := out[i]; coef.Sign() != 0 {
            var a big.Rat
            for j := 1; j < len(divisor); j++ {
                out[i+j].Add(out[i+j], a.Mul(a.Neg(divisor[j]), coef))
            }
        }
    }
    separator := len(out) - (len(divisor) - 1)
    return out[:separator], out[separator:]
}

func main() {
    N := []*big.Rat{
        big.NewRat(1, 1),
        big.NewRat(-12, 1),
        big.NewRat(0, 1),
        big.NewRat(-42, 1)}
    D := []*big.Rat{big.NewRat(1, 1), big.NewRat(-3, 1)}
    Q, R := div(N, D)
    fmt.Printf("%v / %v = %v remainder %v\n", N, D, Q, R)
}
Task: Numbers whose count of divisors is prime


C++: #include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>

int divisor_count(int n) {
    int total = 1;
    for (; (n & 1) == 0; n >>= 1)
        ++total;
    for (int p = 3; p * p <= n; p += 2) {
        int count = 1;
        for (; n % p == 0; n /= p)
            ++count;
        total *= count;
    }
    if (n > 1)
        total *= 2;
    return total;
}

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 main(int argc, char** argv) {
    int limit = 1000;
    switch (argc) {
    case 1:
        break;
    case 2:
        limit = std::strtol(argv[1], nullptr, 10);
        if (limit <= 0) {
            std::cerr << "Invalid limit\n";
            return EXIT_FAILURE;
        }
        break;
    default:
        std::cerr << "usage: " << argv[0] << " [limit]\n";
        return EXIT_FAILURE;
    }
    int width = static_cast<int>(std::ceil(std::log10(limit)));
    int count = 0;
    for (int i = 1;; ++i) {
        int n = i * i;
        if (n >= limit)
            break;
        int divisors = divisor_count(n);
        if (divisors != 2 && is_prime(divisors))
            std::cout << std::setw(width) << n << (++count % 10 == 0 ? '\n' : ' ');
    }
    std::cout << "\nCount: " << count << '\n';
    return EXIT_SUCCESS;
}



Go: package main

import (
    "fmt"
    "rcu"
)

func countDivisors(n int) int {
    count := 0
    i := 1
    k := 1
    if n%2 == 1 {
        k = 2
    }
    for ; i*i <= n; i += k {
        if n%i == 0 {
            count++
            j := n / i
            if j != i {
                count++
            }
        }
    }
    return count
}

func main() {
    const limit = 1e5
    var results []int
    for i := 2; i * i < limit; i++ {
        n := countDivisors(i * i)
        if n > 2 && rcu.IsPrime(n) {
            results = append(results, i * i)
        }
    }
    climit := rcu.Commatize(limit)
    fmt.Printf("Positive integers under %7s whose number of divisors is an odd prime:\n", climit)
    under1000 := 0
    for i, n := range results {
        fmt.Printf("%7s", rcu.Commatize(n))
        if (i+1)%10 == 0 {
            fmt.Println()
        }
        if n < 1000 {
            under1000++
        }
    }
    fmt.Printf("\n\nFound %d such integers (%d under 1,000).\n", len(results), under1000)
}
Task: Odd words


C++: #include <cstdlib>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <utility>
#include <vector>

using word_list = std::vector<std::pair<std::string, std::string>>;

void print_words(std::ostream& out, const word_list& words) {
    int n = 1;
    for (const auto& pair : words) {
        out << std::right << std::setw(2) << n++ << ": "
            << std::left << std::setw(14) << pair.first
            << pair.second << '\n';
    }
}

int main(int argc, char** argv) {
    const char* filename(argc < 2 ? "unixdict.txt" : argv[1]);
    std::ifstream in(filename);
    if (!in) {
        std::cerr << "Cannot open file '" << filename << "'.\n";
        return EXIT_FAILURE;
    }
    const int min_length = 5;
    std::string line;
    std::set<std::string> dictionary;
    while (getline(in, line)) {
        if (line.size() >= min_length)
            dictionary.insert(line);
    }

    word_list odd_words, even_words;

    for (const std::string& word : dictionary) {
        if (word.size() < min_length + 2*(min_length/2))
            continue;
        std::string odd_word, even_word;
        for (auto w = word.begin(); w != word.end(); ++w) {
            odd_word += *w;
            if (++w == word.end())
                break;
            even_word += *w;
        }

        if (dictionary.find(odd_word) != dictionary.end())
            odd_words.emplace_back(word, odd_word);

        if (dictionary.find(even_word) != dictionary.end())
            even_words.emplace_back(word, even_word);
    }

    std::cout << "Odd words:\n";
    print_words(std::cout, odd_words);

    std::cout << "\nEven words:\n";
    print_words(std::cout, even_words);

    return EXIT_SUCCESS;
}



Go: package main

import (
    "bytes"
    "fmt"
    "io/ioutil"
    "log"
    "sort"
    "strings"
)

func main() {
    wordList := "unixdict.txt"
    b, err := ioutil.ReadFile(wordList)
    if err != nil {
        log.Fatal("Error reading file")
    }
    bwords := bytes.Fields(b)
    words := make([]string, len(bwords))
    for i, bword := range bwords {
        words[i] = string(bword)
    }
    count := 0
    fmt.Println("The odd words with length > 4 in", wordList, "are:")
    for _, word := range words {
        rword := []rune(word) 
        if len(rword) > 8 {
            var sb strings.Builder
            for i := 0; i < len(rword); i += 2 {
                sb.WriteRune(rword[i])
            }
            s := sb.String()
            idx := sort.SearchStrings(words, s)      
            if idx < len(words) && words[idx] == s { 
                count = count + 1
                fmt.Printf("%2d: %-12s -> %s\n", count, word, s)
            }
        }
    }
}
Task: Selectively replace multiple instances of a character within a string


C++: #include <map>
#include <iostream>
#include <string>

int main()
{
  std::map<char, std::string> rep = 
    {{'a', "DCaBA"}, 
     {'b', "E"},
     {'r', "Fr"}};

  std::string magic = "abracadabra";

  for(auto it = magic.begin(); it != magic.end(); ++it)
  {
    if(auto f = rep.find(*it); f != rep.end() && !f->second.empty())
    {
      *it = f->second.back();
      f->second.pop_back();
    }
  }

  std::cout << magic << "\n";
}



Go: package main

import (
    "fmt"
    "strings"
)

func main() {
    s := "abracadabra"
    ss := []byte(s)
    var ixs []int
    for ix, c := range s {
        if c == 'a' {
            ixs = append(ixs, ix)
        }
    }
    repl := "ABaCD"
    for i := 0; i < 5; i++ {
        ss[ixs[i]] = repl[i]
    }
    s = string(ss)
    s = strings.Replace(s, "b", "E", 1)
    s = strings.Replace(s, "r", "F", 2)
    s = strings.Replace(s, "F", "r", 1)
    fmt.Println(s)
}
Task: Repunit primes


C++: #include <future>
#include <iomanip>
#include <iostream>
#include <vector>

#include <gmpxx.h>
#include <primesieve.hpp>

std::vector<uint64_t> repunit_primes(uint32_t base,
                                     const std::vector<uint64_t>& primes) {
    std::vector<uint64_t> result;
    for (uint64_t prime : primes) {
        mpz_class repunit(std::string(prime, '1'), base);
        if (mpz_probab_prime_p(repunit.get_mpz_t(), 25) != 0)
            result.push_back(prime);
    }
    return result;
}

int main() {
    std::vector<uint64_t> primes;
    const uint64_t limit = 2700;
    primesieve::generate_primes(limit, &primes);
    std::vector<std::future<std::vector<uint64_t>>> futures;
    for (uint32_t base = 2; base <= 36; ++base) {
        futures.push_back(std::async(repunit_primes, base, primes));
    }
    std::cout << "Repunit prime digits (up to " << limit << ") in:\n";
    for (uint32_t base = 2, i = 0; base <= 36; ++base, ++i) {
        std::cout << "Base " << std::setw(2) << base << ':';
        for (auto digits : futures[i].get())
            std::cout << ' ' << digits;
        std::cout << '\n';
    }
}



Go: package main

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

func main() {
    limit := 2700
    primes := rcu.Primes(limit)
    s := new(big.Int)
    for b := 2; b <= 36; b++ {
        var rPrimes []int
        for _, p := range primes {
            s.SetString(strings.Repeat("1", p), b)
            if s.ProbablyPrime(15) {
                rPrimes = append(rPrimes, p)
            }
        }
        fmt.Printf("Base %2d: %v\n", b, rPrimes)
    }
}
Task: Curzon numbers


C++: #include <cstdint>
#include <iomanip>
#include <iostream>
#include <vector>

uint64_t modpow(uint64_t base, uint64_t exp, uint64_t mod) {
    if (mod == 1)
        return 0;
    uint64_t result = 1;
    base %= mod;
    for (; exp > 0; exp >>= 1) {
        if ((exp & 1) == 1)
            result = (result * base) % mod;
        base = (base * base) % mod;
    }
    return result;
}

bool is_curzon(uint64_t n, uint64_t k) {
    const uint64_t r = k * n;
    return modpow(k, n, r + 1) == r;
}

int main() {
    for (uint64_t k = 2; k <= 10; k += 2) {
        std::cout << "Curzon numbers with base " << k << ":\n";
        uint64_t count = 0, n = 1;
        for (; count < 50; ++n) {
            if (is_curzon(n, k)) {
                std::cout << std::setw(4) << n
                          << (++count % 10 == 0 ? '\n' : ' ');
            }
        }
        for (;;) {
            if (is_curzon(n, k))
                ++count;
            if (count == 1000)
                break;
            ++n;
        }
        std::cout << "1000th Curzon number with base " << k << ": " << n
                  << "\n\n";
    }
    return 0;
}



Go: package main

import (
    "fmt"
    "math/big"
)

func main() {
    zero := big.NewInt(0)
    one := big.NewInt(1)
    for k := int64(2); k <= 10; k += 2 {
        bk := big.NewInt(k)
        fmt.Println("The first 50 Curzon numbers using a base of", k, ":")
        count := 0
        n := int64(1)
        pow := big.NewInt(k)
        z := new(big.Int)
        var curzon50 []int64
        for {
            z.Add(pow, one)
            d := k*n + 1
            bd := big.NewInt(d)
            if z.Rem(z, bd).Cmp(zero) == 0 {
                if count < 50 {
                    curzon50 = append(curzon50, n)
                }
                count++
                if count == 50 {
                    for i := 0; i < len(curzon50); i++ {
                        fmt.Printf("%4d ", curzon50[i])
                        if (i+1)%10 == 0 {
                            fmt.Println()
                        }
                    }
                    fmt.Print("\nOne thousandth: ")
                }
                if count == 1000 {
                    fmt.Println(n)
                    break
                }
            }
            n++
            pow.Mul(pow, bk)
        }
        fmt.Println()
    }
}
Task: Ramanujan's constant


C++: #include <iomanip>
#include <iostream>
#include <boost/math/constants/constants.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using big_float = boost::multiprecision::cpp_dec_float_100;

big_float f(unsigned int n) {
    big_float pi(boost::math::constants::pi<big_float>());
    return exp(sqrt(big_float(n)) * pi);
}

int main() {
    std::cout << "Ramanujan's constant using formula f(N) = exp(pi*sqrt(N)):\n"
        << std::setprecision(80) << f(163) << '\n';
    std::cout << "\nResult with last four Heegner numbers:\n";
    std::cout << std::setprecision(30);
    for (unsigned int n : {19, 43, 67, 163}) {
        auto x = f(n);
        auto c = ceil(x);
        auto pc = 100.0 * (x/c);
        std::cout << "f(" << n << ") = " << x << " = "
            << pc << "% of " << c << '\n';
    }
    return 0;
}



Go: package main

import (
    "fmt"
    "github.com/ALTree/bigfloat"
    "math/big"
)

const (
    prec = 256 
    ps   = "3.1415926535897932384626433832795028841971693993751058209749445923078164"
)

func q(d int64) *big.Float {
    pi, _ := new(big.Float).SetPrec(prec).SetString(ps)
    t := new(big.Float).SetPrec(prec).SetInt64(d)
    t.Sqrt(t)
    t.Mul(pi, t)
    return bigfloat.Exp(t)
}

func main() {
    fmt.Println("Ramanujan's constant to 32 decimal places is:")
    fmt.Printf("%.32f\n", q(163))
    heegners := [4][2]int64{
        {19, 96},
        {43, 960},
        {67, 5280},
        {163, 640320},
    }
    fmt.Println("\nHeegner numbers yielding 'almost' integers:")
    t := new(big.Float).SetPrec(prec)
    for _, h := range heegners {
        qh := q(h[0])
        c := h[1]*h[1]*h[1] + 744
        t.SetInt64(c)
        t.Sub(t, qh)
        fmt.Printf("%3d: %51.32f ≈ %18d (diff: %.32f)\n", h[0], qh, c, t)
    }
}