3.python算法之完全数
2016-03-21 19:03
453 查看
代码:
#!/usr/bin/env python # encoding: utf-8 """ @author: 侠之大者kamil @file: 3.完全数.py @time: 2016/3/21 18:02 """ n = 24 # for i in range(1,n): # if n % i ==0: # print(i) def isperfectNumber(n): a = 1 b = n s = 0 while a < b: if n % a ==0: s += a + b a += 1 b = n/a if a ==b and a*b == n: s +=a return s - n == n for k in range(2,10000): if isperfectNumber(k): print(k) def func(): pass class Main(): def __init__(self): pass if __name__ == '__main__': pass
相关文章推荐
- python的with语句理解
- windows下的python扩展包下载地址
- python yield协程
- 并查集python实现
- Trie树python实现
- 支付宝即时到帐接口的python实现,示例采用django框架
- 安装numpy的坑
- python 下载网页中的图片
- 2.python算法之回形矩阵
- python系列之 RabbitMQ -- Publish/Subscribe
- Ubuntu15.10下如何使用EasyGui模块开发Python GUI
- Ubuntu15.10下如何使用EasyGui模块开发Python GUI
- [LeetCode]题解(python):123-Best Time to Buy and Sell Stock III
- numpy使用指南
- win7 python3.5用pip
- python web开发
- python中给程序加锁之fcntl模块的使用
- PAT 乙级 1017. A除以B
- Learning Python(17)--多线程编程之线程的局部变量
- [LeetCode]题解(python):122-Best Time to Buy and Sell Stock II