Skip to content

Instantly share code, notes, and snippets.

View schie's full-sized avatar
:octocat:
doing stuff

Dustin Schie schie

:octocat:
doing stuff
View GitHub Profile
@schie
schie / Extended_Euclidean_algm.py
Created October 27, 2013 18:14
This python script finds the multiplicative inverse of X mod Y
from sys import stdout
rs = []
qs = [' ',' ']
xs = [1,0]
ys = [0,1]
def gcd(a, b):
if(len(rs) is 0):
rs.append(a)
@schie
schie / PRNG.java
Created October 27, 2013 17:13
This is java program implements the psuedo-random number generator: X(n+1) = (7^5 * X(n)) mod(2^31 - 1) to approximate the value of pi
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class PRNG {
private long seed = 0;
private final long mod = Integer.MAX_VALUE,
seven_pow = (long)Math.pow(7, 5);
@schie
schie / Primitive_root.py
Created October 27, 2013 06:02
This code finds the primitive roots of a relatively small number. It is not optimized for very large numbers.
from fractions import gcd
import copy
def get_relative_primes(number):
# will hold all numbers that are relatively prime to number
rel_primes = set()
# Dictionary: key is primitive root
# value is the set of powers mod number