public class Solution {
public bool CheckPerfectNumber(int num) {
if (num == )
{
return false;
} var sum = ;
for (int i = ; i <= num / ; i++)
{
if (num % i == )
{
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

leetcode507的更多相关文章

  1. [Swift]LeetCode507. 完美数 | Perfect Number

    We define the Perfect Number is a positive integer that is equal to the sum of all its positive divi ...

随机推荐

  1. linux系统时间获取方式

    Linux 操作系统计算系统时间:主要函数:time  localtime  gmtime  asctime  ctime  mktime                    difftime  s ...

  2. IE9(8)跨域(CORS)解决方案

    HTML5中 XMLHttpRequest Level 2 的推出.可以通过在返回的HTTP请求头中加入 Access-Control-Allow-Origin 的设置,让浏览器支持对不同域的AJAX ...

  3. python中多进程

    多进程 什么是进程 进程:正在进行的一个过程或者说一个任务,而负责执行任务的是CPU. 进程和程序的区别 程序仅仅是一堆代码而已,而进程指的是程序的运行过程. 举例 想象以为有着一手好厨艺的科学家肖亚 ...

  4. 【转载】你真的会浮点数与整型数的"互转"吗?

    看了标题,你是不是觉得这TM是哪个iOS彩笔写的入门文章.好的,那咱们先来看看几个例题,看看你有没有白白点进来! int main() { float a = -6.0; int *b = & ...

  5. linux下文件解压

    这几天要学THINKPHP框架了,于是从网上下载了一个压缩包,后缀是.zip的,解压方法为 unzip ###.zip 随便把linux下的.rar方法也写下来,这两个都不常见. unrar    e ...

  6. Loj 114 k大异或和

    Loj 114 k大异或和 构造线性基时有所变化.试图构造一个线性基,使得从高到低位走,异或上一个非 \(0\) 的数,总能变大. 构造时让任意两个 \(bas\) 上有值的 \(i,j\) ,满足 ...

  7. 集合(List、Set、Map)

    List,Set是继承自Collection接口,Map不是 public interface List<E> extends Collection<E> { public i ...

  8. nexus bower 集成使用

    创建nexus bower proxy host 比较简单,如下图: 安装bower && bower-nexus resolver npm install -g bower-nexu ...

  9. eclipse 3.7 中英文自由切换

    最近在学习Java的开发,然后又很多的资料是对于的英文环境讲解,有的资料是对应的中文环境讲解,所以很都对不上号,郁闷啊....... 而且开发的时候,每个人都使用习惯也不相同:有的人喜欢英文界面,有的 ...

  10. anrdroid AVD启动不起来的问题。Waiting for HOME ('android.process.acore') to be launched

    Waiting for HOME ('android.process.acore') to be launched 卡在这里了. 可以到sdk mananager里面先启动起来AVD,然后在eclip ...