Skip to content

Commit

Permalink
Merge pull request #76 from UBC-MDS/peer_review_dhruv_fix
Browse files Browse the repository at this point in the history
Peer review dhruv fix
  • Loading branch information
ThamerD authored Feb 1, 2025
2 parents 1110743 + ff278a1 commit 9481e79
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
42 changes: 31 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Number Theory
# num_theory
[![Documentation Status](https://readthedocs.org/projects/num-theory/badge/?version=latest)](https://num-theory.readthedocs.io/en/latest/?badge=latest)
[![codecov](https://codecov.io/gh/UBC-MDS/num_theory/graph/badge.svg?token=D83Q1sJfPf)](https://codecov.io/gh/UBC-MDS/num_theory)
[![ci-cd](https://github.com/UBC-MDS/num_theory/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/UBC-MDS/num_theory/actions/workflows/ci-cd.yml)
![Python Version](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11-blue.svg)
[![Repo Status](https://img.shields.io/badge/repo%20status-Active-brightgreen)](https://github.com/UBC-MDS/num_theory)
![PyPI](https://img.shields.io/pypi/v/num-theory-euler-problems?color=blue&label=PyPI)

A high-performance Python package for number theory operations, optimized for Project Euler and computational mathematics problems.

A high-performance Python package for number theory operations, optimized for Project Euler and computational mathematics problems. From prime factorization to generating arithmetic progressions, the num_theory package is a versatile tool for students, researchers, and enthusiasts alike. It can also serve as a utility for developing solutions to Project Euler problems.

## Features

Expand All @@ -16,18 +20,18 @@ A high-performance Python package for number theory operations, optimized for Pr
## Installation

```bash
pip install num_theory
pip install num_theory_euler_problems
```

## Usage

### Prime Numbers

```python
from num_theory import get_prime_list_under_n, is_prime, prime_factorization
from num_theory import get_primes, is_prime, prime_factorization

# Generate all primes under 100
primes = get_prime_list_under_n(100)
primes = get_primes(100)

# Check if a number is prime
is_prime(997) # Returns True
Expand All @@ -38,17 +42,33 @@ factors = prime_factorization(84) # Returns [(2, 2), (3, 1), (7, 1)]

### Arithmetic Progressions

Real-Life Application: Saving Money with an Arithmetic Progression
Imagine you want to save money using an increasing savings plan. You start with $50 in the first month, and you decide to increase your savings by $20 each month.

You can use the arithmetic_progression function to calculate:

The amount of money saved each month for 6 months
The total amount saved after 6 months
The exact amount saved in the 6th month

```python
from num_theory import arithmetic_progression

# Generate first 5 terms of AP with a=2, d=3
terms = arithmetic_progression(a=2, d=3, n=5) # [2, 5, 8, 11, 14]
# 1. Get the savings amount for each month
monthly_savings = arithmetic_progression(a=50, d=20, n=6)
print(monthly_savings)
# Output: [50, 70, 90, 110, 130, 150]

# 2. Calculate the total amount saved in 6 months
total_savings = arithmetic_progression(a=50, d=20, n=6, compute_sum=True)
print(total_savings)
# Output: 600.0

# Calculate sum of first 10 terms
sum_ap = arithmetic_progression(a=2, d=3, n=10, compute_sum=True)
# 3. Find the savings amount in the 6th month
sixth_month_savings = arithmetic_progression(a=50, d=20, n=6, nth_term=True)
print(sixth_month_savings)
# Output: 150

# Find the 100th term
nth_term = arithmetic_progression(a=2, d=3, n=100, nth_term=True)
```

## Key Functions
Expand Down
2 changes: 1 addition & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
```{include} ../CHANGELOG.md
```

# v1.1.0:
## v1.1.0:

1. Added detailed documentation file that showcases how the package's functions work, their practical use cases, as well as tutorials on how to use them.
2. Rendered documentation using napoleon Sphinx and uploaded to ReadTheDocs: <https://num-theory.readthedocs.io/en/latest/index.html>
Expand Down
7 changes: 6 additions & 1 deletion src/num_theory/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# read version from installed package
from importlib.metadata import version
__version__ = version("num_theory_euler_problems")
__version__ = version("num_theory_euler_problems")

from num_theory.arithmetic_progression import arithmetic_progression
from num_theory.is_prime import is_prime
from num_theory.prime_factorization import prime_factorization
from num_theory.get_primes import get_primes

0 comments on commit 9481e79

Please sign in to comment.