Given an integer n, return true if it is a power of three. Otherwise, return false.
An integer n is a power of three, if there exists an integer x such that n == 3x.
Example 1:
1 | Input: n = 27 |
Example 2:
1 | Input: n = 0 |
Example 3:
1 | Input: n = 9 |
Example 4:
1 | Input: n = 45 |
判斷某數是不是3的倍數就看他除以3餘數是不是1,並一直重複取餘數。
如果你覺得這篇文章很棒,請你不吝點讚 (゚∀゚)