23 November 2013

Only Perfect Squares Have Odd Number Of Factors

One day I came across a brain teaser,

There are 100 rooms in a hostel numbered 1,2...100.At first the hostel warden opens every room.Then he closes every 2nd room i.e. 2,4,6...100.In the next round he goes to every 3rd room 3,6,..99, if the room is already open he closes it and open closed rooms.This goes on and after the 100th round how many rooms will be open??

To solve this I tried using many methods.One of the methods was to find the number with odd number of factors. If the number had odd number of factors, it will stay opened after all the rounds been complete. Let's say 26. Factors are 1,2,13,26. It'll be opened in round 1, round 2, round 13 and round 26. After that it'll remain untouched. Now let's say a number $n$ has odd number of factors, then it'll remain open after $n$th round.

I tried other combinatorial methods.But all these seemed too long to yield an answer in a reasonable amount of time.After an hour or two one of my friends gave an answer 10.On asking how he arrived at the solution he said he tried upto 10 rounds and only the perfect squares 1, 4 & 9 remained open.

Frankly, I didn't like his answer.It was like mere guess work. And it was not yet conclusive. So the question was do all perfect squares actually have odd number of factors, do other numbers have odd number of factors as well?On factorizing random numbers only perfect squares seemed to have this property.

So we can vaguely say all perfect squares and only perfect squares have odd number of factors.
But I was never a fan of uncertainty, and the fact seemed too elementary to present itself in the form of a proof. After burning tons of glucose in my brain, the proof seemed pretty silly......



Proof:

Let $x$ be a number.
Then $x$ can be represented as
$x=p^a.q^b.r^c.....$
Where p,q,r... are the prime factors.

We can obtain the different factors of x by varying the powers of p,q,r... form 0 to a,b,c... respectively.

Therefore by the fundamental principle of counting we have,
No. of factors = (1+a)(1+b)(1+c)...

For a number to be a perfect square the power of all the prime factors should be even (because a perfect square is the square of a whole number).For all other numbers there will atleast be one factor with odd power.

This implies that the term (1+a)(1+b)(1+c)... is odd for perfect squares where a,b,c... are even and even for other numbers where atleast one of a,b,c... is odd.

Hence proved!!!

No comments:

Post a Comment