当前位置:   article > 正文

LeetCode@Math_507_Perfect_Number

LeetCode@Math_507_Perfect_Number

Problem:



JAVA

  1. public class Solution {
  2. public Boolean checkPerfectNumber(int num)
  3. {
  4. if (num < 2)
  5. return false;
  6. int sum = 1;
  7. for (int x = 2; x * x <= num; x++)
  8. {
  9. if (num % x == 0)
  10. {
  11. sum += x;
  12. sum += num / x;
  13. }
  14. }
  15. return sum == num;
  16. }
  17. }



声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/代码架构师/article/detail/62913
推荐阅读
相关标签
  

闽ICP备14008679号