[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Golf (7 strokes is par!)



On May 1, Jeff Helman said:

>>   if (YOUR CODE HERE) { print "$_ is a power of 2" }
>     if (YOUR CODE HERE) { print "$_ is NOT a power of 2" }
>
>then $_&$_-1 would match your 7.  So I'll bite, what was your 7? (Of
>course, you can send it to me privately if you don't want to spoil it
>quite yet.)

Yes, I am a foolish stupid scum.  My mistake.  You are right with

  $_&$_-1

Do you happen to have the proof for why that is 0 for ONLY powers of 2? :)

-- japhy


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe