# The Security to the Party [Part 4]

A party is being held at a local mansion. The host is very rich and his success is because of one thing — his famous recipe for Spaghetti!

The only guests that may attend are people who correctly reply to the guard at the door.

Here's where you come in. You and a friend are trying to steal this recipe. You sneak by and listen to the passwords.

The first guest arrives. The security says "5", and the guest replies "2".

The second guest arrives. The security says "6", the guest replies "2".

The third guest arrives. The security says "3", the guest replies "2".

Your friend thinks he's got it all figured out so he walks up to the door and the security says "2". He replied "2", and is tarred and feathered and sent away in shame.

Another guest arrives, security says "0" and he says "0" to get in.

You walk up and get a "4" from security. What is your response?

Thanks for the ideas, credits to:

Part 1 was created by warspyking and is found here: The Security to the Party

Part 2 in Mew's version The Security to the Party [Part 2]

Part 3 in Kelvin Barsana's version The Security to the Party [Part 3]

• why is it part 4, its a variation, why do you call it "part"?
– skv
Commented Nov 11, 2014 at 7:32
• @skv, hey - that's a good riddle. I'll post it as a separate question.
– JNF
Commented Nov 11, 2014 at 7:35
• probably because the other are also named part 2, part 3, et cetera Commented Nov 11, 2014 at 7:35
• @skv, ;). just because the rest of them did.
– JNF
Commented Nov 11, 2014 at 7:35
• woohoow, one answer correct! Commented Nov 11, 2014 at 7:36

Respond $1$.
Put x into binary. The number of 1s in the result is the answer. Here is a key for the given numbers: \begin{align}5&=101 &\rightarrow 2 \\ 6&=110 &\rightarrow 2 \\ 3&=11 &\rightarrow 2 \\ 2&=10 &\rightarrow 1 \\ 0&=0 &\rightarrow 0 \\ 4&=100 &\rightarrow 1\end{align}