jackfrued / jackfrued/Python-100-Days
Day05_perfect.py
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 187k
- Forks
- 55.8k
- PR merge metrics
- No merged PRs in 30d
Description
https://github.com/jackfrued/Python-100-Days/blob/master/Day01-15/code/Day05/perfect.py
完美数是除自身外其他所有因子的和正好等于这个数本身的数
for num in range(1, 10000):
result = 0
for factor in range(1, int(math.sqrt(num)) + 1):
if num % factor == 0:
result += factor
if factor > 1 and num // factor != factor:
result += num // factor
if result == num:
print(num)
但是代码结果中包含1,1的因子不是只有自身吗
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Day01-15/code/Day05/perfect.py and run the shown loop to reproduce why 1 is printed. Inspect how factors are accumulated for the boundary case 1; done means the perfect-number output excludes 1 while retaining valid perfect numbers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100