algorithm-in-python/math
2018-12-16 17:09:54 +08:00
..
euler.py Add number theory, string matching, dynamic programming codes 2018-12-16 17:09:54 +08:00
factor.py Add number theory, string matching, dynamic programming codes 2018-12-16 17:09:54 +08:00
gcd.py Add number theory, string matching, dynamic programming codes 2018-12-16 17:09:54 +08:00
isPrime.py Add number theory, string matching, dynamic programming codes 2018-12-16 17:09:54 +08:00
modulo_equation.py Add number theory, string matching, dynamic programming codes 2018-12-16 17:09:54 +08:00
num_weight.py Add computaional method 2018-10-02 21:24:06 +08:00
permute_back_track.py Add header info 2018-12-11 15:57:58 +08:00
permute_cantor.c Add header info 2018-12-11 15:57:58 +08:00
permute_divide_and_conquer.py Add header info 2018-12-11 15:57:58 +08:00
permute_next_arrangement.c Add header info 2018-12-11 15:57:58 +08:00
primesLEn.hs String matching algorithm, permutation algorithm 2018-12-11 15:28:05 +08:00
README.md Add number theory, string matching, dynamic programming codes 2018-12-16 17:09:54 +08:00

Number Theory

See more details on my blog

gcd.py

  • gcd(a,b)
  • xgcd(a,b): return gcd(a,b),x,y, where ax+by = gcd(a,b)

isPrime

  • isPrime(n): using Miller-Rabin primalrity test.
  • primeSieve

euler.py

  • phi(n): euler function
  • sigma(n): return the sum of all factors of n

factor.py

  • factor(n): return a list of numbers that are the factorization of n

modulo_equation.py

Solving modulo equations

solver  = solve()
res = solver.solveLinear(3,6,9)

res = solver.solveHigh(1,8,3,11)

res = solver.solveGroup([(5,11,2),(3,8,5),(4,1,7)])

Permutation