Microsoft Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
1
of 1 vote

For a number to be divisible by 6
- 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.

- Anonymous October 11, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

all 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

- mail2vcp@gmail.com September 29, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I vote for this proof. Makes the reasoning more genuine.

- peace November 04, 2009 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

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.

- Bakhtiar March 27, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Sorry, that's not true. Think about 17 & 19, 19 & 23, 29 & 31, 37 & 41, 41 & 43, etc.

- Anonymous March 12, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Sorry, but 19 & 23 are not twin prime numbers.
P1 and P2 are called twin prime numbers if they are prime and P2 = P1+2

- Anonymous September 25, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Twin primes are pairs of primes of the form (p, p+2).

- vodangkhoa March 12, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Negation

It has to be divided by 2. If it cannot be divided by 3, then suppose it's 3x+1 or 3x-1.

For 3x+1, previous 3x, next 3x+2. Previous is not prime.

For 3x-1, previous 3x-2, next 3x. Next is not prime.

So it cannot be divided by 3.

- Nil March 26, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

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

- Jackie October 03, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Jackie we have to show that number between 2 primes is divisible by 6 and not that its prime.

- Abid January 30, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

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

- yyy May 09, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

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.

- Karthik December 31, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

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.

- Bakhtiar March 27, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

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.

- Bakhtiar March 27, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

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,

- Ken Margo July 03, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

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.

- River Song Innovations January 03, 2018 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More