contextInteger.pl - adds integer related functions primeFactorization, phi, tau, isPrime, randomPrime, lcm, and gcd.
This is a Parser context that adds integer related functions. This forces students to only enter integers as their answers.
Context("Integer")
Generate an array of each prime factor
@a = primeFactorization(1000);
ANS(List(@a)->cmp);
Get the gcd
$b = gcd(5, 2);
ANS($b->cmp);
The the lowest common multiple:
$c = lcm(36, 90);
ANS($c->cmp);
Find phi
$d = phi(365);
ANS($d->cmp);
Find tau
$e = tau(365);
ANS($e->cmp);
Check if prime
$f = isPrime(10); #False
$h = isPrime(5); #True
Get a random prime in a range
$randomPrime = randomPrime(100, 1000);