Skip to content

maths/special_numbers: add Kaprekar number#14563

Open
Kcstring wants to merge 1 commit intoTheAlgorithms:masterfrom
Kcstring:add-kaprekar-number
Open

maths/special_numbers: add Kaprekar number#14563
Kcstring wants to merge 1 commit intoTheAlgorithms:masterfrom
Kcstring:add-kaprekar-number

Conversation

@Kcstring
Copy link
Copy Markdown

Describe your change

Add implementation of Kaprekar numbers to maths/special_numbers/kaprekar_number.py.

A Kaprekar number is a non-negative integer whose square can be split into two parts that sum back to the original number. For example:

  • 9: 9² = 81, and 8 + 1 = 9
  • 45: 45² = 2025, and 20 + 25 = 45
  • 297: 297² = 88209, and 88 + 209 = 297

This implements OEIS A006886.

Reference

Checklist

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • If this pull request resolves one or more open issues then the description above includes the issue number(s) with a closing keyword: "Fixes #ISSUE-NUMBER".

Add is_kaprekar_number() and kaprekar_numbers() with doctests.
Implements OEIS A006886 — numbers whose square splits into two
parts that sum back to the original number.
@algorithms-keeper algorithms-keeper bot added the awaiting reviews This PR is ready to be reviewed label Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviews This PR is ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant