Interview Question
Country: India
Interview Type: In-Person
okay one question why you took P+4 why not P+3 that you need to explain right.. you need to take the combination of P and P+2 to explain this, only P+2 not signify that P+1 is divisible by 3.
No you do not need to complicate things. If P is not divisible by 3 obviously P+3 is not as well. This should be obvious if your interviewer asks for clarification sure go ahead and say what I just said.
P is prime that mean P is not divisible by 2. that gives P+1 is divisible by 2.
P and P+2 is prime that mean P+3 is not divisible by 3 which will makes P divisible by 3 but P is prime. that's why P+4 divisible by 3 as P+2, P+3 are not divisible by 3. that means P+1 divisible by 3.
That mean P+1 divisible by both 2 and 3 that is 6
which proof P+1+6 is divisible by 6 i.e. P+7 divisible by 6.
I can say that even (p + 1) satisfies these conditions.
Just imagine if we have numbers (p-2), (p-1), p, p + 1, p + 2, ..., p + 7
1) Number is divisible by 6 if it divisible by 2 and 3.
We know that each second number is divisible by 2, so it should be (p-1), (p+1), (p + 3), ..., (p + 7), because p and p + 2 are prime and (n > 10)
The same logic for 3
p+1 may not divisible by 6. suppose p=3. p+1=4, then...
the "n>10" in the question doesn't mean p>10, right? (and i have no idea where n comes from....)
n > 10 means that this question works only for number greater then 10, so your sample isn't correct.
-1
"The same logic for 3." No, it's not the same logic for 3. Here, the condition that p+2 is prime comes into play, something that wasn't even considered in the proof for 2.
Every prime number can be written as 6*k+1 or 6*k-1.
so P=6*k-1 and P+2=6*k+1
i.e.
P+7=6*k+6
that is divisible by 6.
I downvoted this because you used a theorem in your proof whose proof is pretty close to the point of this whole problem. Use of that theorem makes this problem way too easy, and so it's clear that an interviewer wants to see you prove that theorem, or else find another elementary proof. You'd be missing the whole point by giving the solution that you gave.
To be divisible by 6 the number has to be divisible by 2 and 3.
- Rayden January 17, 2012- If p is prime than it means it is an odd number. p + 7 MUST be an even number since odd+odd is an even number. Therefore p+7 is divisible by 2.
- If p is prime it means sum of its digits is not divisible by 3. If p+2 is prime than again sum of its digits is not disivible by 3. This means p+1,p+4,p+7 ... is divisible by 3.
As a result p+7 is divisible by 6 always.