Challenge:
Create a program that accepts a positive integer and checks if it can be written in the form of (3^x)-1, where X is another positive integer.
If it can, output X
If it can't, output -1 or a falsy statement.
Example inputs/outputs
Input:
2
It can be written as (3^1) - 1, so we output x which is 1
Output:
1
Input:
26
26 can be written as (3^3) - 1, so we output x (3)
Output:
3
Input:
1024
1024 can't be written in the form of (3^x) - 1, so we output -1
Output:
-1
This is code-golf so least amount of bytes wins
Related OEIS: A024023
3^0-1
a valid output and thus not useable as false, \$\endgroup\$log()
in their answer should confirm it giives the correct answer5
when242
is input. \$\endgroup\$