csnotes/312/math.bc
2019-10-24 10:06:18 -07:00

27 lines
360 B
Plaintext

# What is this?
# Compilation of scripts to written for bc since bc is:
# a. literally a calculator
# b. code is pretty dang readable and useful
# Simple GCD
define gcd(a,b) {
while(a != b) {
if(a>b) {
a = a - b;
}
if(b>a) {
b = b - a;
}
}
return a;
}
define euclid(a, b) {
while(b != 0) {
t = b;
b = a % b;
a = t;
}
return a;
}