Example #1
0
def find_shrike_prime(alphabet):

    print(f"Testing {alphabet}")
    primes = []

    has_odd = False
    digits = []
    for i in reversed(alphabet):
        digits += [i] * i
        if i % 2 == 1:
            has_odd = True

    if has_odd == False:
        return primes

    print(digits)

    ix = 0
    lastcount = 0
    for p in perm_unique(digits):
        ix += 1
        if ix % 100000 == 0 or lastcount != len(primes):
            lastcount = len(primes)
            print(f"Testing: {ix}  Found {lastcount}", end="\r")
        number = int("".join([str(elem) for elem in p]))
        if number % 2 == 0:
            continue
        if number not in primes:
            if is_prime(number):
                primes.append(number)
                # print("Prime !", number)

    return primes
Example #2
0
def find_shrike_prime(digit):

    print(f"Testing {digit}")

    digits = []
    for i in range(1, digit + 1):
        digits += [i] * i

    print(digits)

    primes = []
    ix = 0

    for p in perm_unique(digits):
        #for p in itertools.permutations(digits):
        ix += 1
        if ix % 100000 == 0:
            print(f"Testing: {ix}", end="\r")
        number = int("".join([str(elem) for elem in p]))
        if number % 2 == 0:
            continue
        if number not in primes:
            if is_prime(number):
                primes.append(number)
                # print("Prime !", number)
                return number
    return None
def pi(x):
    ret = 0
    i = 2
    while i <= x:
        if primetest.is_prime(i):
            ret += 1
        i += 1
    return ret
Example #4
0
def primes_a():

    van = 101
    tot = 999
    primes = []
    for i in range(van, tot, 2):
        if is_prime(i):
            primes.append(i)

    print(f"There are {len(primes)} primes between {van} and {tot}")
    print(primes)

    for a, b in itertools.combinations(primes, 2):
        if is_prime(a) and is_prime(b):
            d = a + b - 1
            if is_prime(d):
                yield a, b

    return None
Example #5
0
def find_prime(digits):
    n = ""
    for i in range(digits):
        n += str(random.randint(0, 9))
        num = int(n)
        if num % 2 == 0:
            num += 1
        while is_prime(num) == False:
            num += 2
    return num
def pandecimal_primes():

    digits = [i for i in range(9)]
    for digit_count in range(2, 10):

        print(digits, "Take", digit_count)

        for p in itertools.permutations(digits, digit_count):

            number = int("".join([str(elem) for elem in p]))
            if number % 2 == 0:
                continue
            if is_prime(number):
                yield number

    return None
N = 40000
step = 0.25
x = []
y3 = []
x31 = []
y31 = []
y4 = []

print "Calculating ..."
n = START + 1.5
for i in xrange(START, N):
    f3, f4 = f(n)
    x.append(n)
    y3.append(f3)
    y4.append(f4)

    n_n = int(n)
    if (abs(n_n - n) <= 0.0001) and primetest.is_prime(n_n):
        x31.append(n_n)
        y31.append(f3)

    n += step

print "Plotting ..."
plt.subplot(211)
plt.plot(x, y3)
plt.plot(x31, y31)
plt.subplot(212)
plt.plot(x, y4)
plt.show()
Example #8
0
import math
import primetest
import matplotlib.pyplot as plt

primes = []

def calculate_log(sqrt_p1, sqrt_p2):
    sqrt_1_p2 = 1.0 + sqrt_p2
    r = math.log(sqrt_1_p2/(1.0 + sqrt_p1))
    return r * sqrt_1_p2

N = 1500000

print "Populate primes ..."
for i in xrange(2, N):
    if primetest.is_prime(i):
        primes.append(i);

print "Calculating ..."
sqrt_diff = [] # sqrt diffs
diff = []      # simple diffs
log_calcs = [] # log calcs
x = []
for i in xrange(1, len(primes)):
    sqrt_p2 = math.sqrt(primes[i])
    sqrt_p1 = math.sqrt(primes[i-1])
    sqrt_diff.append(sqrt_p2 - sqrt_p1)
    diff.append(primes[i] - primes[i-1])
    log_calcs.append(calculate_log(sqrt_p1, sqrt_p2))
    x.append(i)