the-honk/python/calculators
2024-10-09 18:02:37 +01:00
..
_helpers Let all calculators take input 2024-10-09 18:02:32 +01:00
Binomial Distribution.py Refactor readmes 2024-10-09 18:02:34 +01:00
Karatsuba Algorithm.md Refactor readmes 2024-10-09 18:02:34 +01:00
Karatsuba Algorithm.py Refactor readmes 2024-10-09 18:02:34 +01:00
Pascal's Triangle.py Pascal's triangle 2024-10-09 18:02:36 +01:00
PMCC.py Refactor readmes 2024-10-09 18:02:34 +01:00
Quadratic nth Term.py Refactor readmes 2024-10-09 18:02:34 +01:00
readme.md Let all calculators take input 2024-10-09 18:02:32 +01:00
SQRT.py Refactor readmes 2024-10-09 18:02:34 +01:00
SRCC.py Refactor readmes 2024-10-09 18:02:34 +01:00
STDEV.py Refactor readmes 2024-10-09 18:02:34 +01:00
Trigometric Functions.py trig! 2024-10-09 18:02:37 +01:00

calculators

Some extra information on the more complex topics (:

Karatsuba Algorithm

The Pseudocode

function karatsuba (num1, num2)
    if (num1 < 10) or (num2 < 10)
        return num1 × num2 /* fall back to traditional multiplication */

    /* Calculates the size of the numbers. */
    m = min (size_base10(num1), size_base10(num2))
    m2 = floor (m / 2)
    /* m2 = ceil (m / 2) will also work */

    /* Split the digit sequences in the middle. */
    high1, low1 = split_at (num1, m2)
    high2, low2 = split_at (num2, m2)

    /* 3 recursive calls made to numbers approximately half the size. */
    z0 = karatsuba (low1, low2)
    z1 = karatsuba (low1 + high1, low2 + high2)
    z2 = karatsuba (high1, high2)

    return (z2 × 10 ^ (m2 × 2)) + ((z1 - z2 - z0) × 10 ^ m2) + z0