To explain the process, I was working on some ProjectEuler.net problems and I had just figured out a formula to solve for triangle numbers efficiently. The next problem needed me to solve for factorials. At the time (before I found out there is not a known equation where you can input n and get the nth factorial) I thought maybe I would work on relating the nth triangle, and n with the nth factorial.
After some time playing around with this, I found that:
If $F_n = n!$ and $T_n$ is the $n^{th}$ triangular number then $F_n\text{ (mod $T_n$)} = n$ if and only if $n+1$ is prime
After some research I found that this is very closely related to Wilson's Theorem:
$( n − 1 ) ! \equiv − 1 ( \text{ mod $n$} )$
I also understand that Triangle Numbers are very closely related to $n$ given the formula mentioned earlier $T_n = {n(n+1) \above 1.5pt 2}$. But these two statements do not seem to explain away the relation between:
$F_n \text{ (mod $T_n$)} \equiv F_n\text{ mod(n+1)}$
At least not in a way that I am grasping. Admittedly, I feel like I'm missing something very basic. So, I have spent my free time for about a week now trying to prove a lack of significance here. Mostly by factoring out various numbers and seeing how n and Tn relate. They obviously do achieve similar results when dividing other numbers besides Fn, but the reason that it lines up for every Fn still seems to escape me.
So I guess my question is: is this completely insignificant? And if not, are there other materials or proofs that could help me dive into this problem further? I can not find many papers written about the relationship between triangles, primes, factorials. Other than this one:
http://www.integers-ejcnt.org/l50/l50.pdf
but this does not seem to be congruent with my problem.
Python code:
def get_fact_num(n):
fact = 1
for x in range(1,n+1):
fact = fact*(x)
return fact
def get_tri_num(n):
tri_num = (n*(n+1))/2
return tri_num
def prime_test(n):
tri = get_tri_num(n)
fact = get_fact_num(n)
mod = fact % tri
mod2 = fact % (n+1)
print n,"::",tri,":",mod,":",mod2
for x in range(4,2000):
prime_test(x)