Skip to content

Commit

Permalink
Added operations
Browse files Browse the repository at this point in the history
  • Loading branch information
P-ict0 committed Jun 22, 2024
1 parent e08dca8 commit 8127913
Showing 1 changed file with 48 additions and 17 deletions.
65 changes: 48 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
- [😁 Welcome!!](#-welcome)
- [Contents](#contents)
- [🧮 AlgebraPy](#-algebrapy)
- [🚀 Quick start](#-quick-start)
- [✨ Features](#-features)
- [📜 Supported operations:](#-supported-operations)
- [📦 Installation and Usage](#-installation-and-usage)
- [📜 Supported operations:](#-supported-operations)


# 🧮 AlgebraPy
Expand All @@ -16,27 +17,22 @@ Simple Python program to perform algebra operations using efficient algorithms l

This program is intended to be lighweight (no dependencies) and very efficient.

# ✨ Features
# 🚀 Quick start

Can operate with numbers from base 2 to base 16. Without converting between bases in each operation.
```bash
pip install AlgebraPy
```

Note: _**Each number has to be inputted and will be returned as a string, except the base.**_
You can import the module:
```python
import AlgebraPy as ap
```

# 📜 Supported operations:
# ✨ Features

- Addition
- Subtraction
- Multiplication (Normal "primary school method" + Karatsuba algorithm)
- Division
- GCD of 2 numbers (Extended Euclidean algorithm)
- Modular Arithmetic:
- Reduction
- Addition
- Subtraction
- Multiplication
- Inversion
Can operate with numbers from base 2 to base 16. Without converting between bases in each operation.

<hr>
Note: _**Each number has to be inputted and will be returned as a string, except the base.**_

# 📦 Installation and Usage

Expand Down Expand Up @@ -65,3 +61,38 @@ pa.extEuclid("-1460","44321521", 7)
pa.modularInversion("9a1aa8a02232", "a6a722a", 11)
# Output: '3293845'
```

# 📜 Supported operations:

- Addition
- Subtraction
- Multiplication (Normal "primary school method" + Karatsuba algorithm)
- Division
- GCD of 2 numbers (Extended Euclidean algorithm)
- Modular Arithmetic:
- Reduction
- Addition
- Subtraction
- Multiplication
- Inversion

<hr>

| Function Name | Input | Output |
|------------------------|--------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| removeLeadingZeros | a (str) | str: The modified string with all leading zeros removed |
| greaterOrEqual | x (str), y (str) | bool: True if x is greater than or equal to y, False otherwise |
| divide | x (str), y (str), r (int) = 10 | str: The quotient of x divided by y, expressed in radix r |
| elementaryAdd | x (str), y (str), c (str), r (int) = 10 | tuple: (result (str), carry (str)) |
| elementarySub | x (str), y (str), c (str), r (int) = 10 | tuple: (result (str), carry (str)) |
| elementaryMult | x (str), y (str), z (str), c (str), r (int) = 10 | tuple: (result (str), carry (str)) |
| add | x (str), y (str), r (int) = 10 | str: Result of x + y in radix r |
| subtract | x (str), y (str), r (int) = 10 | str: Result of x - y in radix r |
| multiply | x (str), y (str), r (int) = 10 | str: Result of x * y in radix r |
| karatsuba | x (str), y (str), r (int) = 10 | str: Result of x * y using Karatsuba algorithm in radix r |
| extEuclid | x (str), y (str), r (int) = 10 | tuple: (gcd (str), a (str), b (str)) |
| modularReduction | n (str), m (str), r (int) = 10 | str: Result of n mod m in radix r |
| modularAddition | x (str), y (str), m (str), r (int) = 10 | str: Result of (x + y) mod m in radix r |
| modularSubtraction | x (str), y (str), m (str), r (int) = 10 | str: Result of (x - y) mod m in radix r |
| modularMultiplication | x (str), y (str), m (str), r (int) = 10 | str: Result of (x * y) mod m in radix r |
| modularInversion | a (str), m (str), r (int) = 10 | str: Inverse of a mod m in radix r, or prints "Inverse does not exist" |

0 comments on commit 8127913

Please sign in to comment.