## FF. Hostile Flowers

This is a beautiful puzzle that appears in many different forms.

Arp and Bif are playing with a line of 100 flowers. Each flower is originally open. When an open flower is touched it closes, and when a closed flower is touched, it opens. First they touch every flower in the line, then they touch every other flower in the line, then they touch every third flower, etc.

When done, which flowers are open, which flowers are closed?

## 0x616c said,

March 5, 2009 at 3:01 am

Nice!

[spoiler]

Any flower whose number is a perfect square is closed.

Not a proof, but to quickly verify:

ruby -e ‘a=100;b=Array.new(a+1,1);1.upto(a){|c|c.step(a,c){|d|b[d]^=1}};1.upto(a){|e|print”flower #{e} is “;puts 1==b[e]?”open”:”closed”}’

[/spoiler]

## avgbody said,

March 6, 2009 at 12:49 pm

[spoiler] With the hint of looking at the first 10, it seems to be that the square numbers are the ones left closed. [/spoiler]

## strauss said,

March 8, 2009 at 1:45 am

The real issue here is:

[spoiler] What characterizes numbers with an odd number of divisors? [/spoiler]

This can be thought of as:

[spoiler] If p is a prime, then how many factors does p^n have?[/spoiler]

[spoiler] If A and B are relatively prime, then the number of factors of A times the number of factors of B = the number of factors of A B (why? Try it out for 2^3 3^3 to see what’s going on) [/spoiler]

## dfollett76 said,

March 8, 2009 at 12:08 pm

I’ve spent some time thinking about this before and came up with the wrong answer, this time I tried making an excel spreadsheet that simulated the process and got it right. The key was this function =IF($A3/D$2-INT($A3/D$2)=0,IF(C3=0,1,0),C3)

in this example A3 was the flower number, D2 was the number of the trial (i.e. 3 if every third locker was being opened) ad C3 was the lockers current state.

## Philo said,

March 12, 2009 at 7:29 pm

The problem appears to be stated incorrectly (given your solution). You need to start with all the flowers closed to wind up with closed perfect squares, at least, if you’re going to begin by touching them all once.