Skip to content

Instantly share code, notes, and snippets.

View srawlins's full-sized avatar

Sam Rawlins srawlins

View GitHub Profile
@jingoro
jingoro / modular_arithmetic.rb
Created April 14, 2012 23:43
Ruby modular arithmetic
# Some modular arithmetic helper methods useful for number theory or
# cryptography.
#
# # Examples
#
# Compute the greatest common denominator of 114 and 48:
#
# gcd(114, 48) #=> 6
#
# Compute `a` and `b` such that `a*x + b*y = gcd(x, y)`: