Skip to content

Instantly share code, notes, and snippets.

View IsuraManchanayake's full-sized avatar
🏠
Working from home

Isura D. Manchanayake IsuraManchanayake

🏠
Working from home
  • University of Melbourne
  • Melbourne
View GitHub Profile
#include <iostream>
int main() {
std::cout << "Hello World!" << std::endl;
return 0;
}
#include <iostream>
#include <ctime>
#include <vector>
#include <functional>
using namespace std;
int L = 100000000;
int R = 100100000;
primality test using primality_naive(int64_t)
L = 100000 : R = 200000
test 1 duration : 19.897 s
test 2 duration : 20.491 s
average of 2 test(s) : 20.198 s
primality test using primality_sqrt_bound(int64_t)
L = 100000000 : R = 100100000
test 1 duration : 0.761 s
test 2 duration : 0.762 s
test 3 duration : 0.764 s
test 4 duration : 0.771 s
test 5 duration : 0.741 s
test 6 duration : 0.741 s
test 7 duration : 0.769 s
test 8 duration : 0.744 s
primality test using primality_sqrt_bound_coprime_6(int64_t)
L = 100000000 : R = 100100000
test 1 duration : 0.278 s
test 2 duration : 0.269 s
test 3 duration : 0.283 s
test 4 duration : 0.258 s
test 5 duration : 0.263 s
test 6 duration : 0.272 s
test 7 duration : 0.262 s
test 8 duration : 0.265 s
@IsuraManchanayake
IsuraManchanayake / output.txt
Last active December 10, 2016 12:41
deterministic variant of Miller Rabbin method
primality test using primality_miller_rabin(int64_t)
L = 100000000 : R = 100100000
test 1 duration : 0.861 s
test 2 duration : 0.853 s
test 3 duration : 0.856 s
test 4 duration : 0.844 s
test 5 duration : 0.84 s
test 6 duration : 0.835 s
test 7 duration : 0.839 s
test 8 duration : 0.839 s
primality test using primality_sqrt_bound_coprime_2(int64_t)
L = 100000000 : R = 100100000
test 1 duration : 0.418 s
test 2 duration : 0.393 s
test 3 duration : 0.397 s
test 4 duration : 0.406 s
test 5 duration : 0.379 s
test 6 duration : 0.381 s
test 7 duration : 0.383 s
test 8 duration : 0.383 s
primality test using primality_sqrt_bound_coprime_30(int64_t)
L = 100000000 : R = 100100000
test 1 duration : 0.281 s
test 2 duration : 0.225 s
test 3 duration : 0.222 s
test 4 duration : 0.227 s
test 5 duration : 0.226 s
test 6 duration : 0.223 s
test 7 duration : 0.223 s
test 8 duration : 0.225 s
int tt = 10, it = 1;
double total = 0.;
cout << "primality test using primality_miller_rabin_probabilistic(int64_t)" << endl;
cout << "Miller Rabin iteration count = " << it << endl;
cout << "L : " << L << " R : " << R << endl;
for(int k = 0, c = 0, t = clock(); k < tt; k++, c = 0, t = clock()) {
for(int i = L; i <= R; i++)
c += primality_miller_rabin_probabilistic(i, it);
double time = (clock() - t) / (CLOCKS_PER_SEC + 0.);
total += time;
var maxIterations;
var maxVal;
var height;
var width;
function preload() {
maxIterations = 200;
maxVal = 50;