Microsoft Interview Question
Software Engineer / Developersall prime numbers are of the form 6x+1 or 6x-1
so to be twin primes they should be 6x-1 and 6x+1 for some x
so the number netween them is 6x which is divided by 6
The question should say that the prime numbers selected is greater than 3
Assume m, m+1, m+2 are three consecutive numbers, m and m+2 are twin primes ,
The rule is that in any 3 consecutive numbers any one number should be divisible by 2 and by 3. (For example: 4,5,6 , 4 is divisible by 2, 6 is divisible by 3)
Since m and m+2 are prime numbers, m+1 has to be divisible by 3 and 2. This answer is valid if m>3.
negation:
the twin primes are p and p+2, the number between is X=p+1.
if x=p+1=6K+1, then p=6k, not prime, thus this assumption is not true
if x=p+1=6k+2, then p+2=6k+3=3(2k+1),not prime, also not true
if x=p+1=6k+3, then p=6k+2, not prime, not true
...
if x=p+1=6k+5, then p=6k+4, not prime, not true.
thus x=6K+6 and is divisible by 6
Series of numbers mod 6 will give
0 1 2 3 4 5 0 1 2 3 .....
its obvious frome here that Num Mod 6 giving 0 is not prime
same for mod 2 and 4 they can be prime. Since it divisible 2
Mod 3 one will be divisble 3 if not by 6. No chance of prime
Left are only 1 and 5 modulo.
If there are twin no they have to be in 5 and 1 modulo only.
The no in between them will be Mod 0 which is divisble by 6
Since the prime numbers other than 2 cannot be even,the 2 twin primes are odd and hence the number between them is even.
Now consider any 3 consecutive numbers,any one of them need to be divisible by 3.since both the prime numbers are not divisible by any number,the middle number is divisible by 3.
The question should say that the prime numbers selected is greater than 3
Assume m, m+1, m+2 are three consecutive numbers, m and m+2 are twin primes ,
The rule is that in any 3 consecutive numbers any one number should be divisible by 2 and by 3. (For example: 4,5,6 , 4 is divisible by 2, 6 is divisible by 3)
Since m and m+2 are twin prime numbers, m+1 has to be divisible by 3 and 2. This answer is valid if m>3.
The question should say that the prime numbers selected is greater than 3
Assume m, m+1, m+2 are three consecutive numbers, m and m+2 are twin primes ,
The rule is that in any 3 consecutive numbers any one number should be divisible by 2 and by 3. (For example: 4,5,6 , 4 is divisible by 2, 6 is divisible by 3)
Since m and m+2 are prime numbers, m+1 has to be divisible by 3 and 2. This answer is valid if m>3.
I've checked the first 33 prime pairs (m<1000) and m+1 is always divisible by 3. What interests me is, if this postulate is always true, as I intuitively feel it is , then its a shortcut to deciding whether any odd number following or before a prime is also a prime (ie if the even number between them is NOT divisible by 3 ,then one of the odd numbers is not prime. The exception is the pair 3,5.where 4 is not divisible by 3.So it 'works' for all m >=5,
Assumptions:
N is the set of minimum twin numbers of any twin primes. i.e. {5, 11, 17, 29 ...}
n is an element of N
n > 3
(n + 1) is always even
N is a subset of Natural numbers
------------------------------------------------------------------------
s = n, n+1, n+2 -> this represents the sum of three numbers (prime twin minimum, even number, prime twin max)
s = 3(n+1)
s is in the set of Natural numbers and must be even. Consider, 3 is odd, (n+1) is even. Any product of an odd number and even number is an even number.
s forms a subset of Natural numbers where the minimum step value for s is 3*(minimum even number i.e. 2), or 6. Therefore all even numbers between twin primes are divisible by 6.
For a number to be divisible by 6
- Anonymous October 11, 2006- Must be divisible by both 2 and 3
Since it is between 2 primes, it is even and hence divisible by 2. Since every third number is divisible by three and the two adjacent ones of this number are prime, this number must also be divisible by three. Hence every numer between twin primes (except (3, 5)) is divisible by 6.