Lunski's Clutter

This is a place to put my clutters, no matter you like it or not, welcome here.

0%

326. Power of Three

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
2
Input: n = 27
Output: true

Example 2:

1
2
Input: n = 0
Output: false

Example 3:

1
2
Input: n = 9
Output: true

Example 4:

1
2
Input: n = 45
Output: false

判斷某數是不是3的倍數就看他除以3餘數是不是1,並一直重複取餘數。


如果你覺得這篇文章很棒,請你不吝點讚 (゚∀゚)

Welcome to my other publishing channels