You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
512 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package class34;
public class Problem_0326_PowerOfThree {
// 如果一个数字是3的某次幂那么这个数一定只含有3这个质数因子
// 1162261467是int型范围内最大的3的幂它是3的19次方
// 这个1162261467只含有3这个质数因子如果n也是只含有3这个质数因子那么
// 1162261467 % n == 0
// 反之如果1162261467 % n != 0 说明n一定含有其他因子
public static boolean isPowerOfThree(int n) {
return (n > 0 && 1162261467 % n == 0);
}
}