X = X + Y # Now X holds the sum of X and Y
Y = X - Y # Subtract Y from the sum, so Y becomes the original X
X = X - Y # Subtract the new Y (original X) from the sum, so X becomes the original Y
X = -5
Y = 2
print(f"X = {X}, Y = {Y}")
X = X + Y # Now X holds the sum of X and Y
Y = X - Y # Subtract Y from the sum, so Y becomes the original X
X = X - Y # Subtract the new Y (original X) from the sum, so X becomes the original Y
print(f"X = {X}, Y = {Y}")
but here we have small values that are easier to work with.I'm using the RSA algorithm, but I'm not using large primes
import sympy
# Given values
n = 391
e = 291
# Step 1: Factorize n to find p and q
factors = sympy.factorint(n)
p, q = factors.keys()
# Step 2: Calculate φ(n) = (p - 1) * (q - 1)
phi_n = (p - 1) * (q - 1)
# Step 3: Find the modular inverse of e modulo φ(n) to get d
d = sympy.mod_inverse(e, phi_n)
# Print the results
print(f"Factors of n: p = {p}, q = {q}")
print(f"φ(n) = {phi_n}")
print(f"Private key d = {d}")
75 291
115 251
pseudocode
function zork()
return a random number from 0 to 4
procedure sim()
define buckets as an array of 5 integers
initialise buckets to all 0
loop 20 times
buckets[zork()] += 1
end loop
print buckets
buckets[zork()] += 1
buckets[zork()] = buckets[zork()] + 1
p = true
IF (v != 1)
i = 0
WHILE ((v != n-1) AND p)
IF (i == s-1)
p = false
ELSE
i = i + 1
v = (v^2) % n
PRINT p
p = true
FOR i = 1 TO s
y = (v^2) % n
IF (y == 1 AND v != 1 AND v != n-1)
exit FOR loop
v = y
IF (v != 1)
p = false
PRINT p
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.