326. Power of Three
Given an integer, write a function to determine if it is a power of three.
Follow up:
Could you do it without using any loop / recursion?
递归或循环
递归和循环的做法很简单,就是不停的除以3,直到不能整除,结果是1的话,就是3的指数,否则则不是。
但是这个题目的follow up不让用循环和递归。
|
|
|
|
Given an integer, write a function to determine if it is a power of three.
Follow up:
Could you do it without using any loop / recursion?
递归和循环的做法很简单,就是不停的除以3,直到不能整除,结果是1的话,就是3的指数,否则则不是。
但是这个题目的follow up不让用循环和递归。
|
|
|
|