Tuesday, May 19, 2015

A probabilistic coincidence: the set of primitive roots modulo a prime number p, when p > 61, contains two roots r1,r2 whose sum is the next prime to p

I wrote about this observation at Mathematics Stack Exchange, and basically it is the weirdest thing I have seen so far, but finally it is based on probabilities as one fellow at MSE explained!

Take the set of Primitive Roots Modulo p (link to definition here) of a prime number p, Pr(p). For those primes p > 61 there is always a pair of primitive roots r1 and r2 in Pr(p) whose sum is the next prime to the current prime p, I will call it N(p).


I have tested this with Python, in the interval [62,7000] being always true. E.g.:


For p∈[1,61] there are only five counterexamples: {2,3,5,7,61} and for the rest of primes the observation is true as well.

Sunday, May 17, 2015

Conjecture about the product of the primitive roots modulo a prime number

Related with my previous post, I found a similar property in the product of the primitive roots modulo p, I will call them, Pr_p, where p is a prime number. 

Let P(n) be the previous prime smaller than n, then:






And N(n) be the next prime greater than n, then:






So it seems that the product of the primitive roots modulo a prime p is at a distance d1 of its previous closer prime and a distance d2 of its closer next prime, being d1 and d2 = 1 or a prime number.













(*) Notice that in the sample by chance d1 and d2 incidentally are exactly the previous and next prime numbers of the original p = 17.

I asked about this possible property, and the answer I received from one of the fellows at Mathematics Stack Exchange was very amazing, you can see here the question and the answer.

I have tested it in the interval of primes in [1,1000]. This is the Python code:

#import cProfile

def primitive_roots():
    import fractions
    from sympy import divisor_count, totient, mobius, is_primitive_root, nextprime, prevprime
    from math import floor, log, sqrt
    from gmpy2 import mpz, c_mod, mul, is_odd, is_prime, add, sub, divexact, set_cache, is_square, digits, div, gcd

    # Print calculation time
    def printTime():
        import time, datetime
        ts = time.time()
        st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
        print(st+"\n")

    def prim_root_prod(value):
        calprod = 1
        for i in range (1,value):
            if is_primitive_root(i,value)

               calprod = calprod * i
        return calprod

              
    printTime()

    print("N(Pr_p) TEST")   
    n=nextprime(1)
    while n<1000:
        calprod = prim_root_prod(n)
        res = nextprime(calprod)-calprod
        if is_prime(res) or (res == 1):
            print("Success for " + str(n) + " , d2 is " + str(res))
        else:
            print("If this message appears, then the conjecture is false for " + str(n) + " because the distance d2 is not a prime number: " + str(res))
   
        n=nextprime(n)

      
    print("P(Pr_p) TEST")   
    n=nextprime(3)
    while n<1000:
        calprod = prim_root_prod(n)
        res = calprod-prevprime(calprod)
        if is_prime(res) or (res == 1):
            print("Success for " + str(n) + " , d1 is " + str(res))
        else:
            print("If this message appears, then the conjecture is false for " + str(n) + " becase the distance d1 is not a prime number: " +  str(res))
   
        n=nextprime(n)
   
    printTime()
       
#cProfile.run('primitive_roots_test()')
primitive_roots_test()

 

Monday, May 11, 2015

About Fortunate numbers and other similar expressions

Recently I stumbled upon a very interesting question in the Mathematics Stack Exchange (here). It turned out to be an already known conjecture, that I did not know at all, and is really amazing. 

Let N(n) be the next prime greater than or equal to n. The conjecture states that N(n!)-n! is either 0 (case n = 2), 1 or a prime number. It has been tested for the first 2000 terms only.

As one of the fellows at MSE said, the origin of it is the Fortunate numbers, using for the above expression the primorials instead of the factorials. And so far, the known expressions E(n) that are able to comply with the expression N(E(n))-E(n) is 0,1,or Prime, are the Fortunate numbers and the n! version stated by Amarnath Murthy in the OEIS page (link here).

In my humble opinion, I think that the rule might be generalized to something like this (1):





Where E(n) is a function or expression based on n, Natural number.

I have been trying other expressions and the following ones seem to comply as well (maybe they are known, but I just did some trial-error). I tested both over the interval [1,600] with Python:





I wondered if it was possible to find an expression E(n) < n! and the following one seems to work as well! (at least up to 600, my computer takes time for the factorial tests in Python).






I found other expressions E(n) < E2(n) that seem also to comply with the original rule, but I am still testing them. The topic is really amazing. I tried also for instance Catalan numbers, but they do not comply.

So the interesting point about those conjectures would be:












This is the Python code I used for testing:
# Elementary number theory
# -- Computational number theory
# --- Prime number generator function
# ---- Fortunate numbers variations
# by David M. @ https://hobbymaths.blogspot.com

#import cProfile

def fortunate():

    import fractions
    from sympy import divisor_count, totient, factorial, nextprime
    from math import floor, log, sqrt
    from gmpy2 import mpz, c_mod, mul, is_odd, is_prime, add, sub, divexact, set_cache, is_square, digits, div, gcd

    # Print calculation time
    def printTime():
        import time, datetime
        ts = time.time()
        st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
        print(st+"\n")

    printTime()

    lop1 = []
    lop2 = []
    lop3 = []


    # Factorial version
    print("Factorial variation")
    for n in range(1,600):
        myf = factorial(n)
        np = nextprime(myf)
        if is_prime(int(np-myf)) or (np-myf==1) or (np-myf==0):
            lop1.append(np-myf)
        else:
            print("If this message appears, the conjecture is false")

    str1 = ""
    for i in lop1:
        str1 = str1 + str(i) + "\t"
    print(str1)


    # 2^i*i! version
    print("Power * factorial")
    num = 1
    for n in range(1,600):
        num = factorial(n) * (2**n)
        den = 1
        res = num//den
        np = nextprime(res)
        if is_prime(int(np-res)) or (np-res==1) or (np-res==0):
            lop2.append(np-res)
        else:
            print("If this message appears, the conjecture is false")

    str1 = ""
    for i in lop1:
        str1 = str1 + str(i) + "\t"
    print(str1)

   
    # i!/2^(i//2) version
    print("Factorial / power")
    num = 1
    for n in range(1,300):
        num = factorial(n)
        den = 2**(n//2)
        res = num//den
        np = nextprime(res)
        if is_prime(int(np-res)) or (np-res==1) or (np-res==0):
            lop3.append(np-res)
        else:
            print("If this message appears, the conjecture is false")
   
    str1 = ""
    for i in lop1:
        str1 = str1 + str(i) + "\t"
    print(str1)

    printTime()
       
#cProfile.run('fortunate()')
fortunate()

I will update if I find new expressions like the ones above. If somebody knows more about the topic, please let me know.

UPDATE: I published at OEIS an example of this kind of sequences! (A257886 click here).