![]() ![]() Note that the division of the current number by \2 is implicit. In effect this divides the number by its smallest prime factor, \2 for example, 1296 will initially be captured as \4 = 1296/2 = 648. ![]() Next inside this inner loop, it uses the greedy capture group \4 to capture the number's largest factor smaller than itself: (?=(x+)(\4+)$). The first time through this loop, this test is useless, but its purpose will become apparent later. Then, at the beginning of a loop that is repeated 4 times, it tests to see if the current number is divisible by \2, with (?=\2+$). For example, with 1296 (6^4) it will initially capture \2 = 2. As such, this factor is guaranteed to be prime. Zero is also matched.įirst it uses a lazy capture group \2 to capture the number's smallest factor larger than 1. A final quotient of 1 indicates that the original value was indeed a fourth power this completes the match. As such the quotient at each step is always a fourth power, iff the original value was a fourth power. It works by repeatedly dividing away the smallest fourth power of a prime that the current value is divisible by. I need to thank deadcode for bumping it back up to the top. This is, in my opinion, one of the most interesting problems on the site. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |