1. ## Prime pattern

Can anyone see why this generates Prime?

2. ## Re: Prime pattern

9!-8!+7!-6!+5!-4!+3!-2!+1!=326981=79*4139

It was coincidence that terms 3 through 8 produce prime numbers.

3. ## Re: Prime pattern

thanks...I was getting excited...

4. ## Re: Prime pattern

Do we have a way of summing alternating factorials like this? They look like a fascinating series...

5. ## Re: Prime pattern

Originally Posted by rodders
Do we have a way of summing alternating factorials like this? They look like a fascinating series...
$a_1 = 1!$
$a_2 = 2!-1!$
$a_3 = 3!-2!+1! = 3!-(2!-1!) = 3!-a_2$
$a_4 = 4!-3!+2!-1! = 4!-(3!-(2!-1!)) = 4!-a_3$
.
.
.
$a_n = n! - a_{n-1}$

In Wolframalpha, it is the af function. Example:

http://www.wolframalpha.com/input/?i=af(10)

6. ## Re: Prime pattern

This may be what you are looking for:

Wolfram|Alpha: Computational Knowledge Engine

7. ## Re: Prime pattern

Originally Posted by SlipEternal
$a_1 = 1!$
$a_2 = 2!-1!$
$a_3 = 3!-2!+1! = 3!-(2!-1!) = 3!-a_2$
$a_4 = 4!-3!+2!-1! = 4!-(3!-(2!-1!)) = 4!-a_3$
.
.
.
$a_n = n! - a_{n-1}$

In Wolframalpha, it is the af function. Example:

Wolfram|Alpha: Computational Knowledge Engine
Can this be expressed in closed form or only as a recurrence relation? can't see what the af function is!

8. ## Re: Prime pattern

Originally Posted by rodders
Can this be expressed in closed form or only as a recurrence relation? can't see what the af function is!
There are many ways of representing it. Another way is with the Exponential Integral, the Gamma function, and the Incomplete Gamma Function:

Wolfram|Alpha: Computational Knowledge Engine

But, in terms of simple functions, no, it has no closed form.

To see that the two equations are equal is not easy. Here is the function with n=1 to 10.

http://www.wolframalpha.com/input/?i...7Bn,1,10%7D%5D

9. ## Re: Prime pattern

Found an interesting fact about these sum..

Miodrag Zivković proved in 1999 that there are only a finite number of alternating factorials that are also prime numbers, since 3612703 divides af(3612702) and therefore divides af(n) for all n ≥ 3612702. As of 2006, the known primes and probable primes are af(n) for (sequence A001272 in the OEIS)

n = 3, 4, 5, 6, 7, 8, 10, 15, 19, 41, 59, 61, 105, 160, 661, 2653, 3069, 3943, 4053, 4998, 8275, 9158, 11164
Only the values up to n = 661 have been proved prime in 2006. af(661) is approximately 7.818097272875 × 101578.

Don't quite get the reasoning why there is a limit to the number of primes though

10. ## Re: Prime pattern

Reasoning to the limit:
If 3612703 divides af(n) for all $n\ge 3612702$, then af(n) is a composite number, not a prime number. Therefore, only af(1) through af(3612701) could possibly be prime. To show that af(n) is composite:

Induction Hypothesis: for all $n\ge 3612702, 3612703$ divides $\text{af}(n)$.
Base of Induction: for $n=3612702$, Zivković showed that 3612703 divides $\text{af}(n)$. (I do not have the computing power to prove that statement is true, but if it is true, the rest of the induction follows).
Induction assumption: Suppose 3612703 divides af(n) for some $n\ge 3612702$.
Then by the induction hypothesis, there exists integer $k$ such that $\text{af}(n) = 3612703k$.
Next, we want to show that 3612703 divides $\text{af}(n+1) = (n+1)! - \text{af}(n)$. Since $n\ge 3612702$, we know there exists integer $q$ such that $(n+1)! = 3612703q$ (property of the factorial, we know that $q$ is the product of all positive integers no larger than $n+1$ not equal to 3612703).
So, $\text{af}(n+1) = (n+1)! - \text{af}(n) = 3612703q-3612703k = 3612703(q-k)$.
Since the difference of two integers (q-k) is an integer, it shows that $\text{af}(n+1)$ is a composite number divisible by 3612703.
Therefore, by the principle of mathematical induction, the hypothesis holds for all $n\ge 3612702$.

So, as long as 3712703 really does divide af(3612702), there are only a finite number of primes. I will go ahead and trust Zivković rather than try to prove it myself.

11. ## Re: Prime pattern

Actually, I can prove that af(3612702) is divisible by 3612703 with an R program:

fact <- 1
af <- 1
for( i in 2:3612702 ) {
fact <- (i * fact) %% 3612703
af <- (fact - af) %% 3612703
}
af

If the final result gives 0, then af(3612702) is divisible by 3612703.
When I ran the code, it did, in fact, give 0.