标签:== target get else number i++ ret problems for
public class Solution { public bool CheckPerfectNumber(int num) { if (num == 1) { return false; } var sum = 1; for (int i = 2; i <= num / 2; i++) { if (num % i == 0) { var j = num / i; if (i <= j) { sum += i; sum += num / i; if (sum > num) { break; } } else { break; } } } if (sum == num) { return true; } else { return false; } } }
https://leetcode.com/problems/perfect-number/#/description
标签:== target get else number i++ ret problems for
原文地址:http://www.cnblogs.com/asenyang/p/6759044.html