Skip to content

feat: add perfect number #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

ei-sugimoto
Copy link
Contributor

Added perfect numbers with test.

Copy link
Contributor

@appgurueu appgurueu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function should be called isPerfectNumber (without the s).

You could optimize it by only iterating up to the square root of n and adding both i and n / i to the sum in each iteration if i divides n (special case: if i is exactly the square root, you don't want to add it twice; I'd deal by this with excluding it from the loop and processing it separately).

Otherwise looks fine.

@ei-sugimoto ei-sugimoto changed the title feat: add perfect numbers feat: add perfect number Jan 31, 2024
@ei-sugimoto
Copy link
Contributor Author

Thank you for the review, I have implemented your suggestion.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (master@c8a4b98). Click here to learn what that means.

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #221   +/-   ##
=========================================
  Coverage          ?   96.27%           
=========================================
  Files             ?       97           
  Lines             ?     1797           
  Branches          ?      347           
=========================================
  Hits              ?     1730           
  Misses            ?       67           
  Partials          ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@raklaptudirm raklaptudirm merged commit 296e4a5 into TheAlgorithms:master Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants