Skip to main content

A lightweight Python package to check whether a number is a Krishnamurthy (Strong) number.

Project description

Krishnamurthy Utils

A lightweight, beginner-friendly, and efficient Python package for checking whether a number is a Krishnamurthy Number (also known as a Strong Number or Peterson Number).

The package provides a simple API that can be integrated into educational projects, coding practice, mathematical applications, and Python programs.


What is a Krishnamurthy Number?

A Krishnamurthy Number is a positive integer whose value is equal to the sum of the factorials of its individual digits.

Formula

Number = Σ Factorial(each digit)

For example,

145

1! + 4! + 5!
= 1 + 24 + 120
= 145

Since the sum equals the original number, 145 is a Krishnamurthy Number.

Another example,

40585

4! + 0! + 5! + 8! + 5!
= 24 + 1 + 120 + 40320 + 120
= 40585

Features

  • Simple API
  • Lightweight package
  • Fast execution
  • Beginner friendly
  • Zero external dependencies
  • Easy integration into any Python project
  • Ideal for coding interviews and DSA practice
  • Well documented

Installation

Install directly from PyPI.

pip install krishnamurthy-utils

Or upgrade to the latest version.

pip install --upgrade krishnamurthy-utils

Quick Start

from krishnamurthy_utils import is_kmn

print(is_kmn(145))

Output

True

Usage Examples

Example 1

from krishnamurthy_utils import is_kmn

print(is_kmn(145))

Output

True

Example 2

from krishnamurthy_utils import is_kmn

print(is_kmn(40585))

Output

True

Example 3

from krishnamurthy_utils import is_kmn

print(is_kmn(123))

Output

False

Example 4

from krishnamurthy_utils import is_kmn

numbers = [1, 2, 145, 40585, 123, 567]

for number in numbers:
    print(number, is_kmn(number))

Output

1 True
2 True
145 True
40585 True
123 False
567 False

Function Reference

is_kmn(number)

Checks whether the given integer is a Krishnamurthy Number.

Parameters

Parameter Type Description
number int Positive integer

Returns

Type Description
bool Returns True if the number is a Krishnamurthy Number, otherwise False.

Example

from krishnamurthy_utils import is_kmn

number = int(input("Enter a number: "))

if is_kmn(number):
    print("Krishnamurthy Number")
else:
    print("Not a Krishnamurthy Number")

Known Krishnamurthy Numbers

The known Krishnamurthy Numbers in decimal representation are

1
2
145
40585

Time Complexity

Time Complexity : O(d)

Space Complexity : O(1)

Where d is the number of digits.


Requirements

  • Python 3.8+
  • No external libraries required

Project Structure

krishnamurthy-utils
│
├── src
│   └── krishnamurthy_utils
│       ├── __init__.py
│       └── krishnamurthy.py
│
├── tests
│   └── test_krishnamurthy.py
│
├── README.md
├── LICENSE
└── pyproject.toml

Contributing

Contributions are welcome!

You can contribute by:

  • Reporting bugs
  • Improving documentation
  • Adding test cases
  • Optimizing the implementation
  • Suggesting new features

Fork the repository, create a feature branch, and submit a pull request.


License

This project is licensed under the Apache License 2.0.

You are free to use, modify, distribute, and contribute to this project under the terms of the Apache License 2.0.

See the LICENSE file for complete details.


Author

Krishna

Engineer | Python Developer | AI & ML Enthusiast


Support

If you find this package useful,

⭐ Star the repository

⭐ Share it with others

⭐ Contribute to its development

Happy Coding!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

krishnamurthy_utils-0.1.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

krishnamurthy_utils-0.1.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file krishnamurthy_utils-0.1.0.tar.gz.

File metadata

  • Download URL: krishnamurthy_utils-0.1.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for krishnamurthy_utils-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1a6ff4b6d24edd3c976f8b8c297488f57699bb7b7a27bafcf63909558f43d989
MD5 626da462d6eb657610f35cb5de4a0701
BLAKE2b-256 6516dac948a17e59eedb52aba19930a53d5c232378428ecda4a32342743bf8b7

See more details on using hashes here.

File details

Details for the file krishnamurthy_utils-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for krishnamurthy_utils-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0cdbaec1aaf6a2e5a0c30c87e519d94a718156242fba5917169f020d0c65ab34
MD5 d2d6ea4619eed30d7eed5508bb6e7cc7
BLAKE2b-256 660678a58c4a5f1f960d4a392e513d9da8e2cf1b61858a1a65300a1da4b22482

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page