Skip to main content

The most comprehensive Python library for number classification — 3000+ number types

Project description

numclassify

The most comprehensive Python library for number classification — 3000+ number types, zero dependencies.

PyPI version Python versions License MIT Tests


Why numclassify?

Most number-theory libraries — labmath, eulerlib, pyntlib — answer computational questions: factor this, find the GCD, generate primes up to N.

numclassify answers a different question: what kind of number is this?

  • 153 → Armstrong, Narcissistic, Harshad, Triangular, Abundant…
  • 1729 → Taxicab (Hardy-Ramanujan), Zeisel, Carmichael…
  • 28 → Perfect, Triangular, Hexagonal, Semiprime…

Over 3000 named number types, instant lookup, no external dependencies.


Installation

pip install numclassify

Or clone and install in editable mode:

git clone https://github.com/aratrikghosh2011-tech/numclassify.git
cd numclassify
pip install -e .

Quick Start

import numclassify as nc

# Boolean checks
nc.is_prime(17)          # True
nc.is_armstrong(153)     # True
nc.is_perfect(28)        # True

# All true properties of a number
nc.get_true_properties(1729)
# ['taxicab', 'zeisel', 'carmichael', 'odd', 'composite',
#  'deficient', 'squarefree', 'cubefree', 'powerful_not_perfect_power']

# Search a range
nc.find_in_range(nc.is_armstrong, 1, 10000)
# [1, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 371, 407, 1634, 8208, 9474]

# Pretty-print everything about a number
nc.print_properties(153)
# ┌─────────────────────────────────────────┐
# │  Properties of 153                      │
# ├─────────────────────────────────────────┤
# │  armstrong         ✓                    │
# │  harshad           ✓                    │
# │  triangular        ✓                    │
# │  ...                                    │
# └─────────────────────────────────────────┘

CLI

numclassify ships with a fully-featured command-line interface.

Check a number:

$ numclassify check 1729
1729 properties:
  taxicab           carmichael        zeisel            odd               deficient         squarefree      

JSON output (pipe-friendly):

$ numclassify check 153 --json
{"armstrong": true, "harshad": true, "triangular": true, "abundant": true, ...}

Find numbers of a type:

$ numclassify find armstrong --limit 10
1, 2, 3, 4, 5, 6, 7, 8, 9, 153

Filter a range:

$ numclassify range 1 20 --filter prime
2, 3, 5, 7, 11, 13, 17, 19

List all registered types in a category:

$ numclassify list --category primes
twin_prime, mersenne_prime, sophie_germain_prime, safe_prime,
wilson_prime, fermat_prime, ... (41 total)

Get info about a type:

$ numclassify info armstrong
Name:        armstrong
Category:    digital_invariants
Description: A number equal to the sum of its digits each raised to the power
             of the number of digits. Also called narcissistic numbers.
OEIS:        A005188
Examples:    1, 2, 3, 153, 370, 371, 407, 1634, 8208, 9474

Number Categories

Category Count Examples
Polygonal (figurate) 998 Triangular, Square, Pentagonal … Chiliagonal
Centered Polygonal 998 Centered Triangular, Centered Hexagonal …
Prime families 41 Twin, Mersenne, Sophie Germain, Wilson, Safe…
Digital invariants 10 Armstrong, Spy, Harshad, Disarium, Happy, Neon…
Divisor-based 27 Perfect, Abundant, Weird, Amicable, Practical…
Sequences 15 Fibonacci, Lucas, Catalan, Bell, Padovan…
Powers 13 Perfect Square, Taxicab, Sum of Two Squares…
Number theory 14 Evil, Carmichael, Keith, Autobiographical…
Combinatorial 10 Factorial, Primorial, Subfactorial, Catalan…
Recreational 5 Kaprekar, Automorphic, Palindrome…
Total 3000+

Adding Your Own Number Type

The @register decorator lets you plug in custom types in 6 lines:

from numclassify import register

@register(name="my_type", category="custom")
def is_my_type(n: int) -> bool:
    return n > 0 and n % 7 == 0 and str(n)[0] == "4"

# Now works everywhere
import numclassify as nc
nc.is_my_type(49)              # False  (doesn't start with 4)
nc.is_my_type(42)              # True
nc.get_true_properties(42)     # [..., 'my_type', ...]

API Reference

Function Description
is_prime(n) Returns True if n is a standard prime
is_armstrong(n) Returns True if n is a narcissistic/Armstrong number
get_all_properties(n) Dict of every registered type → True/False
get_true_properties(n) List of only the properties that are True
print_properties(n) Pretty-prints a formatted property table to stdout
find_in_range(fn, lo, hi) All integers in [lo, hi] where fn returns True
find_all_in_range(lo, hi) Dict mapping every number in range to its true properties
count_properties(n) Count of how many types apply to n
most_special_in_range(lo, hi) The number in [lo, hi] with the most true properties

Full API docs: github.com/aratrikghosh2011-tech/numclassify


Requirements

  • Python 3.8 or higher
  • Zero external dependencies

License

MIT © 2026 Aratrik Ghosh

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

numclassify-0.1.1.tar.gz (42.5 kB view details)

Uploaded Source

Built Distribution

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

numclassify-0.1.1-py3-none-any.whl (45.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: numclassify-0.1.1.tar.gz
  • Upload date:
  • Size: 42.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for numclassify-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8866d3fe41ab5eb8d116253f0eb893b07dec3a1f64d9db77702760997f25c9e7
MD5 bd391a73076e7cff9f452d4d0a6545d9
BLAKE2b-256 6f20f3046b7d0df33fb21d0f6a2733ed8b847b04df9ca0249a9bd3eda7641681

See more details on using hashes here.

Provenance

The following attestation bundles were made for numclassify-0.1.1.tar.gz:

Publisher: publish.yml on aratrikghosh2011-tech/numclassify

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: numclassify-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 45.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for numclassify-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9b3856d05198a0a9b0f27b818e2043584a31d0492570bdcf322ddf9a7139d735
MD5 be826576ac87c10b30ed8519cad5a728
BLAKE2b-256 72de84aa86842ed0e753e4a80c39c77617b51131c80ad34e04513b4a4341173c

See more details on using hashes here.

Provenance

The following attestation bundles were made for numclassify-0.1.1-py3-none-any.whl:

Publisher: publish.yml on aratrikghosh2011-tech/numclassify

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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