A lightweight Python library for fundamental number theory operations
Project description
PyFunMath 🔢
PyFunMath is a lightweight and beginner-friendly Python library designed to perform fun and fundamental number theory operations. Whether you're a student, hobbyist, or Python learner, this library offers handy utilities to explore properties of numbers like primality, digit patterns, and mathematical characteristics.
✨ Features
- Check if a number is prime
- Identify Armstrong numbers
- Detect palindromes (numeric or string)
- Check for perfect numbers
- Count total number of digits in an integer
- Calculate sum of digits
- Check if a number is a happy number
- List all divisors of a number
In your Python project:
from pyfunmath import ( is_prime, is_armstrong, count_digits, is_palindrome, is_perfect_number, sum_of_digits, is_happy_number, divisors, )
How to Use
-
is_prime(n)
Checks if a number is prime.
Example:
is_prime(7) # True -
is_armstrong(n)
Checks if a number is an Armstrong number (e.g., 153 = 1³ + 5³ + 3³).
Example:
is_armstrong(153) # True -
count_digits(n)
Returns the total number of digits in a number.
Example:
count_digits(12345) # 5 -
is_palindrome(x)
Checks if a number or string is a palindrome. Case-insensitive and ignores non-alphanumeric characters.
Example:
is_palindrome("Madam") # True
is_palindrome(121) # True -
is_perfect_number(n)
Checks if a number is perfect (equal to the sum of its proper divisors).
Example:
is_perfect_number(28) # True -
sum_of_digits(n)
Returns the sum of all digits in a number.
Example:
sum_of_digits(123) # 6 -
is_happy_number(n)
Determines if a number is a happy number.
Example:
is_happy_number(19) # True -
divisors(n)
Returns a list of all divisors of the number.
Example:
divisors(12) # [1, 2, 3, 4, 6, 12]
🧑💻 Developer
Siva Naga Lakshmi Somepalli
Artificial Intelligence & Data Science
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyfunmath-0.1.0.tar.gz.
File metadata
- Download URL: pyfunmath-0.1.0.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c548f034a577755ecc2a5ed78a2167a14ecd22065f8f5bc82fc9ae52c6f4f1d
|
|
| MD5 |
47e44dd9e2196a5559f5cc8b4025f9c6
|
|
| BLAKE2b-256 |
b1c243ddb9ff47328f5851be5c62f41c7a02160f873b69e38c264ff694dea1cd
|
File details
Details for the file pyfunmath-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyfunmath-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1128458cea6dfac7590ea288cc86fd53161c0c03412904101b7bc7abc6bd8b7
|
|
| MD5 |
f765478e06f8c7158c187dac73ab22fd
|
|
| BLAKE2b-256 |
4a8c5eaea116ea48db3ad282117ef14ef2329f93bb0fe33110f6958abc71976d
|