Problems
One can show that if an integer of the form 2**k-1 is prime then
k must be prime.
Proof
Suppose that k=m*n is a non-trivial factorization. Then
2^m = 1 (mod (2^m-1))
2^(m*n) = 1 (mod (2^m-1))
so 2^m-1 is a non-trivial factor of 2^k-1
Problem Find the smallest prime p such that 2**p-1 is not prime
Answer
First, define a function:
You can try factoring f(p) as p ranges through the set of primes.
For example,
This gets tedious after a while, so let's use Axiom's stream facility.
A streamm is essentially an infinite sequence. First, we create a stream
consisting of the positive integers:
Now, we create a stream consisting of the primes:
Here is the 25th prime:
Next, create the stream of numbers of the form 2**p-1 with p prime:
Finally, form the stream of factorizations of the elements of numbers:
You can see that the fifth number in the stream (2047=23*89) is the first
one that has a non-trivial factorization. Since 2**11=2048, the solution
to the problem is 11.
Here is another way to see that 2047 is the first number in the stream
that is composite:
Problem: Find the smallest positive integer n such that
n**2-n+41 is not prime.
Answer: When n=41, n**2-n+41=41**2, which certainly isn't prime.
Is there any smaller integer that works? Here are the first 40 values:
Now have Axiom factor the numbers on this list:
You can see that 41 is the smallest positive integer n such that
n**2-n+41 is not prime.