def main(): x = readinput("x") y = readinput("y") if y > x: x, y = y, x ans = gcd(x, y) print("GCD of %d and %d = %d" % (x, y, ans))
def main(): x = readinput("x") y = readinput("y") if y > x: x, y = y, x ans = gcd(x, y) print ("GCD of %d and %d = %d" % (x, y, ans))
def main(): print ("X^Y % N") x = readinput("X") y = readinput("Y") N = readinput("N") ans = modular_exp(x, y, N) print ("(%d^%d) %% %d = %d" % (x, y, N, ans))
def main(): print("X^Y % N") x = readinput("X") y = readinput("Y") N = readinput("N") ans = modular_exp(x, y, N) print("(%d^%d) %% %d = %d" % (x, y, N, ans))
def test_numpower(): while True: x = readinput("X") n = readinput("N") ans = numpower(x, n) print("%d^%d is: %d\n" % (x, n, ans)) print("press \"n\" to exit, any other key to cont.") inp = input() if inp.strip() == 'n': break
def main(): num = readinput() clist = findconstant(num) print("showing c values: ") print(clist) ch = input("based on above c values. enter c: ") c = float(ch) # c = clist[-1] print("Now Lets verify if for c=%0.2f the equation Fn <= 2^(c*n) holds" % (c)) print("First lets choose \"n\" value") num = readinput() verifyc(c, num)
def main(): num = readinput() clist = findconstant(num) print ("showing c values: ") print (clist) ch = input("based on above c values. enter c: ") c = float(ch) # c = clist[-1] print ("Now Lets verify if for c=%0.2f the equation Fn <= 2^(c*n) holds" % (c)) print ("First lets choose \"n\" value") num = readinput() verifyc(c, num)
def send_message(e, N): print ("Alish wishes to send message x to Bob") print ("She looks up his public key (N, e) and sends him message" " y = x^e mod N") x = readinput("message x") y = modular_exp(x, e, N) return y
def main(): clist = [0.5, 1, 2] print ("Please enter \"n\" value below") n = readinput() for c in clist: theta = calc_theta(c, n) print("for c:%0.2f and n:%d, theta is: %0.2f" % (c, n, theta))
def main(): num = readinput() for n in range(num+1): fib = findfibonacci(n) sys.stdout.write(str(fib) + " "), sys.stdout.write("\n") print ("Finding fibonacci through expression 2**(0.694*n)") for n in range(num): fib = findfibexpr(n) sys.stdout.write(str(fib) + " "), sys.stdout.write("\n") print ("Enter number for fast fibonacci") num = readinput() fib = findfibopoly(num) print ("fib %d is: %d" % (num, fib))
def send_message(e, N): print("Alish wishes to send message x to Bob") print("She looks up his public key (N, e) and sends him message" " y = x^e mod N") x = readinput("message x") y = modular_exp(x, e, N) return y
def main(): num = readinput() for n in range(num + 1): fib = findfibonacci(n) sys.stdout.write(str(fib) + " "), sys.stdout.write("\n") print("Finding fibonacci through expression 2**(0.694*n)") for n in range(num): fib = findfibexpr(n) sys.stdout.write(str(fib) + " "), sys.stdout.write("\n") print("Enter number for fast fibonacci") num = readinput() fib = findfibopoly(num) print("fib %d is: %d" % (num, fib))
def main(): print("Fermat's little theorem for primality") print("If p is prime then for every 1 <= a < p") print("a^(p-1) ≡ 1 (mod) p") p = readinput("prime candidate") if isprime(p): print("%d is Prime Number" % p) else: print("%d is Not a Prime Number" % p)
def main(): print ("Fermat's little theorem for primality") print ("If p is prime then for every 1 <= a < p") print ("a^(p-1) ≡ 1 (mod) p") p = readinput("prime candidate") if isprime(p): print ("%d is Prime Number" % p) else: print ("%d is Not a Prime Number" % p)
def main(): a = readinput("x value") b = readinput("y value") x = bin(a) y = bin(b) x = x[2:] y = y[2:] xlen = len(x) ylen = len(y) diff = abs(xlen - ylen) z = "0" * diff if xlen < ylen: x = z + x elif ylen < xlen: y = z + y ans = multiply(x, y) print ("x in bin: ", x) print ("y in bin: ", y) print ("x * y = ", ans)
def main(): print("Fermat's little theorem for primality") print("If p is prime then for every 1 <= a < p") print("a^(p-1) ≡ 1 (mod) p") p = readinput("prime candidate") if isprime(p): print("%d is Prime Number" % p) else: print("%d is Not a Prime Number" % p) for i in range(100000): if isprime(4): print("we are getting 4 as prime") print("Done!")
def main(): print ("Fermat's little theorem for primality") print ("If p is prime then for every 1 <= a < p") print ("a^(p-1) ≡ 1 (mod) p") p = readinput("prime candidate") if isprime(p): print ("%d is Prime Number" % p) else: print ("%d is Not a Prime Number" % p) for i in range(100000): if isprime(4): print("we are getting 4 as prime") print ("Done!")
def main(): num = readinput("n >= 2") p = random_prime(num) print ("Random Prime less than %d: %d" % (num, p)) test_random_prime()
def main(): x = readinput("X") y = readinput("Y") ans = division(x, y) print("%d / %d = Quotient: %d, Remainder: %d" % (x, y, ans[0], ans[1]))
def main(): num = readinput("n >= 2") p = random_prime(num) print("Random Prime less than %d: %d" % (num, p)) test_random_prime()
def main(): num = readinput("which fibonacci number") fib = fibonacci(num) print("fib digit len: ", len(str(fib[0]))) print("%d fibonacci is: %d" % (num, fib[0])) print("log(fib): ", math.log(fib[0], 2))
def main(): a = readinput("a") b = readinput("b") (x, y, d) = extended_euclid(a, b) print("ax + by = d") print("x=%d, y=%d, d=%d" % (x, y, d))
def main(): n = readinput("n value") count = checkinverses(n) print("%d integers have inverses with modulo %d" % (count, n))
def main(): num = readinput("which fibonacci? ") fib = get_fibonacci(num) print ("%d fibonacci: %d" % (num, fib))
def main(): x = readinput("X: ") y = readinput("Y: ") ans = french_mult(x, y) print("%d x %d: %d" % (x, y, ans))
def main(): num = readinput("n value for series") harmonic_series(num)
def main(): x = readinput("X: ") y = readinput("Y: ") ans = french_mult(x, y) print ("%d x %d: %d" % (x, y, ans))
def main(): a = readinput("a") b = readinput("b") (x, y, d) = extended_euclid(a, b) print ("ax + by = d") print ("x=%d, y=%d, d=%d" % (x, y, d))
def main(): print("empirical study of log(n!) = Θ(nlog(n))") n = readinput("n value") test_expression(n)
def main(): print("To calculate: X^(-1) mod N") x = readinput("X") n = readinput("N") ans = inverse_modulo(x, n) print("Ans: ", ans)
def test_binary_converter(): num = readinput("decimal number") bnum = tobinary(num) print ("binary: ", bnum)
def main(): print ("To calculate: X^(-1) mod N") x = readinput("X") n = readinput("N") ans = inverse_modulo(x, n) print ("Ans: ", ans)
def main(): num = readinput("which fibonacci number") fib = fibonacci(num) print ("fib digit len: ", len(str(fib[0]))) print ("%d fibonacci is: %d" % (num, fib[0])) print ("log(fib): ", math.log(fib[0], 2))