#K9296. Determine if a Number is a Power of Three
Determine if a Number is a Power of Three
Determine if a Number is a Power of Three
You are given an integer n
. Your task is to determine whether n
is a power of three.
An integer n
is said to be a power of three if there exists an integer k such that \(n = 3^k\), where \(k \geq 0\). For example, 1 (\(3^0\)), 3 (\(3^1\)), 9 (\(3^2\)), 27 (\(3^3\)) are all powers of three, whereas 0, 2, 45, etc. are not.
You need to read the input from stdin and output your answer to stdout. Print True
if the given number is a power of three, and False
otherwise.
inputFormat
The input consists of a single integer n
provided via stdin.
outputFormat
Output a single line containing either True
or False
depending on whether n
is a power of three.
27
True