-
Notifications
You must be signed in to change notification settings - Fork 1
Math
bkul edited this page Jun 29, 2016
·
1 revision
Fith includes a burgeoning math library.
Right now, it is mainly focused on number theory.
To load the math library, place *math* load at the beginning of your program.
factorial ( n -- n! )- Calculate the factorial of the top of the stack. Requires a positive integer.
prime? ( n -- t/f )- Determine whether or not the top of the stack is prime. Requires a positive integer.
gcd ( a b -- gcd )- Calculate the greatest common divisor of the top two stack elements using Euclid's algorithm. Requires two positive integers.
coprime? ( a b -- t/f )- Determine whether or not the top two stack elements are coprime, i.e., whether or not their GCD is 1. Requires two positive integers.
totient ( n -- tot )- Calculates Euler's totient function for the top of the stack. Requires a positive integer.