Robbie Hatley's Solutions To The Weekly Challenge #254
For those not familiar with "The Weekly Challenge", it is a weekly programming puzzle with two parts, cycling every Sunday. You can find it here: The Weekly Challenge This week (2024-01-28 through 2024-02-03) is weekly challenge #254. Its tasks are as follows: Task 254-1: Three Power Submitted by: Mohammad S Anwar You are given a positive integer, $n. Write a script to return true if the given integer is a power of three otherwise return false. Example 1: Input: $n = 27 Output: true 27 = 3 ^ 3 Example 2: Input: $n = 0 Output: true 0 = 0 ^ 3 Example 3: Input: $n = 6 Output: false First of all, I had to think hard whether "Three Power" means "x^3" or "3^x". But the latter would be "3 to the x power", whereas the former is "x to the 3 power", so I think "Three Power" means "x^3". This is also corroborated by Example #2, which states that 0 is a "Three Power" because "0 = 0^3", ...