XP is just a number | |
PerlMonks |
Re: This may be more of a math questionby Corion (Patriarch) |
on May 15, 2002 at 21:18 UTC ( [id://166850]=note: print w/replies, xml ) | Need Help?? |
Well, it's simply true - we need first to look at the lowest bit of a and b. If they are both zero, then, obviously, a^b == (a^b) + (1^1) == (a+1)^(b+1).This occurs 25% of the time. The next (interesting) case would be that both lowest bits of a and b are 1, and the second lowest bit of both, a and b, is 0. Then again, a^b == (a+1)^(b+1). I'm not sure, if this method of counting will arrive at 33% overall, as there are some other possibilities (like a=5, b=6) which I didn't count, but 25% is close enough to 33% to mark this method of generating random numbers as dangerous.
In Section
Seekers of Perl Wisdom
|
|