Skip to content

Add Kaprekar number checker to special_numbers #12723

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

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed May 11, 2025
commit 7692d03294ca0242e9140cc97ba8e3289b6b604d
4 changes: 2 additions & 2 deletions maths/special_numbers/kaprekar_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def is_kaprekar_number(n: int) -> bool:
>>> is_kaprekar_number(10)
False
"""
square = str(n ** 2)
square = str(n**2)
for i in range(1, len(square)):
left, right = square[:i], square[i:]
if int(right) == 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems this check is not needed anymore.

Expand All @@ -31,5 +31,5 @@ def is_kaprekar_number(n: int) -> bool:

if __name__ == "__main__":
import doctest

doctest.testmod()