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).

2 comments:

  1. I found no counterexamples for E2 and E3 to 2000. E1 I did to 1000 and it is still churning away looking to 2000. E3 did complete much faster, but still took something like 10 hours on my laptop.

    ReplyDelete
  2. Hi! thank you for confirming that! It is really appreciated, I am a developer but... I use tablets a home!! so I do not have a good computer to run long tests :) All the test I do are at my job with my quite old laptop where I installed Python (now PARI). Sometimes I run tests three or four hours (I am lucky that they are compatible with my job) so what you did is very appreciated.

    ReplyDelete