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.1.tar.gz (7.5 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.1-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: krishnamurthy_utils-0.1.1.tar.gz
  • Upload date:
  • Size: 7.5 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.1.tar.gz
Algorithm Hash digest
SHA256 b4e47251b46bbcb8b2b6d0dd38d2109eb501a1777e25a5acdba802de70d0ef32
MD5 41076c314bfb31cddf11205453786375
BLAKE2b-256 9ed42e712e8cfc21662d6d4461a117285b52804e44fcb35b5766e9afca5437e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for krishnamurthy_utils-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 553cfc72d006fe653c8557c869c12ca891b0eb36e573e71eb1a043f0e8c940b6
MD5 fa72fa762cbd452a5cb7090758b3df75
BLAKE2b-256 596bab196f50bf052780335ad4990ceb5a9453cc269e7699b951c09434367d9e

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