Post Reply 
(32SII) Solving a Single Congruence Equation for the HP 32Sii
01-17-2014, 09:04 PM
Post: #3
RE: Solving a Single Congruence Equation for the HP 32Sii
This is the correspoding Python code:

Code:

def solve(a, b, n):
    p, q, m = 0, 1, n
    while a != 0:
        d = n // a
        p, q = q, p - d*q
        n, a = a, n - d*a
    x = p * b % m
    return x if x > 0 else x + m

print(solve(5, 3, 17))

Visualize Execution

Now how cool is that? Imagine you write the program for your calculator and view the stack and registers? Single-step forward and back through the program?

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Solving a Single Congruence Equation for the HP 32Sii - Thomas Klemm - 01-17-2014 09:04 PM



User(s) browsing this thread: 1 Guest(s)