All Downloads are FREE. Search and download functionalities are using the official Maven repository.

z3-z3-4.12.6.src.test.prime_generator.cpp Maven / Gradle / Ivy

There is a newer version: 4.13.0.1
Show newest version
/*++
Copyright (c) 2011 Microsoft Corporation

Module Name:

    prime_generator.cpp

Abstract:

    Prime generator

Author:

    Leonardo (leonardo) 2011-12-23

Notes:

--*/
#include "util/mpz.h"
#include "util/prime_generator.h"
#include 

void tst_prime_generator() {
    unsynch_mpz_manager m;
    scoped_mpz sqrt_p(m);

    prime_generator gen;
    gen.initialize();
    for (unsigned i = 0; i < 10000; i++) {
        uint64_t p = gen(i);
        std::cout << p << ", ";
        if (i % 11 == 0) std::cout << "\n";
        std::cout.flush();
        if (p == 2)
            continue;
        m.set(sqrt_p, p);
        m.root(sqrt_p, 2);
        uint64_t k = m.get_uint64(sqrt_p);
        for (uint64_t i = 2; i <= k; i++) {
            ENSURE(p % i != 0);
        }
    }
    gen.finalize();
    std::cout << std::endl;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy