Monday, May 30, 2022

Is 2 taken to the power of one million minus 1 a prime number? NO! and I didn't have to calculate it to find out......I used some LSD

 Mersenne prime numbers are ones that have the form 2^N - 1.  Not all (actually relatively few) prime numbers have this relationship, and of course not all numbers that can be calculated using that formula are prime.  For a simple example, 2^4 = 16.  16 - 1 = 15, which is divisible by 3 and 5 -- so it's not a prime number.

You will have to read on to learn about the LSD.

Prime numbers are important when it comes to generating highly secure encryption codes, so they have been of interest for a long while.

For some reason, perhaps yet another sleepless night, I started thinking about powers of two, in terms of their digits.  More specifically, if the least-significant digit of them has any kind of pattern to it.  Some simple mental arithmetic revealed the answer, and it should become obvious when I write down the first few powers of 2, starting with N = 1:   2, 4, 8, 16, 32, 64,128, 256....and so on.  Looking at the Least-Significant Digit (the LSD, gotcha!!!) of this series we see:  2 4 8 6 2 4 8 6 .... so we have a sequence of 4 digits that endlessly repeats:  2 4 8 6 .... A little more mental gyrations and I came up with a way to predict what the first digit of any power of 2 is.  It does take a little more math, requiring the use of the Residue function.  Residues are calculted by getting the remainder of long division.  It's easier to show by example, like this:  take a look at 10/4.  Long division gives us a quotient of 2 because 4*2 is the nearest multiple of 4 that is closest (but not larger than) 10.  10 - (4*2) gives us the remainder, 2.  That is what the Residue function produces -- the remainder.  So if we examine the Remainder of (any whole number)/4, we find they can only be either zero, one, two or three.

Now let's create an array with the values [6,2,4,8] in it.  The array entries are a little different than what you might expect since the indices into the array are 0, 1, 2 and 3....4 isn't possible because its residue is zero.

Now let's determine what the LSD of 2 taken to the one-millionth power must be.  Some simple math says that the remainder of 1,000,000/4 is 0 (this will be true for any power of 10 greater than 1).  The first entry in the array is a 6, so we know that the LSD of 2 to the millionth power is a 6.

Recall that Mersenne primes have the form 2^n - 1.  If we subtract 1 from 6, we get 5, and all numbers ending in 5 are divisible by 5.  Therefore, it is NOT a prime number.

For the same reason, we also can say that any number calculated by evaluating 2^(10^n) -1 also are NOT primes, as long as n is greater than 1.

It so happens that we can use a similar but slightly more complicated scheme to determine what the next-most-least-significant digit (NMLSD) of a power of 2 is.  I won't go into much of it here except to say that the sequence has a length of 20.  The NMLSD of 2^1,000,000 is a seven.

After that the sequences become ever-longer so the approach becomes less and less viable.  If nothing else, it becomes necessary to accurately calculate some pretty large numbers, just to examine their smallest parts.

No comments:

Post a Comment