Number Theory
- The Modulus Operator. The code a % b returns the remainder of $a$ divided by $b$.
- The Integer Quotient. The code a // b returns the largest integer that will go into $a$ $b$ times.
- The Quotient-Remainder Method. The .quo_rem() method returns the quotient and remainder of $a$ divided by $b$.
- The Divides Method. The code a.divides(b) returns TRUE of $a$ divides $b$.
- The Divisors Command The command divisors(a) returns all the divisors of integer $a$.
- The Sigma Command The command sigma( a, b) returns the divisors of integer $a$ raised to power $b$ and summed.
- The Greatest Common Divisor Command. The command gcd(a, b) returns the greatest common divisor of $a$ and $b$.
- The Extended Greatest Common Divisor Command. The command xgcd(a, b)) returns the greatest common divisor $d$ of $a$ and $b$ and integers $r$ and $s$ such that $d = ra + sb$.
- The Least Common Multiple Command.The command lcm() returns the least common multiple of the integers passed to it.
- The Is-Prime Method. The .is_prime() method returns true if the number is prime.
- The Random Prime Command. The command random_prime(a) generates a random prime between 2 and $a$.
- The Prime Range Command. The command prime_range(a,b) generates a list of primes between $a$ and $b-1$.
- The Next Prime Command. The command next_prime(a) returns the next prime after $a$..
- The nth Prime Command. The command nth_prime(a) returns the $a$ prime.
- The Previous Prime Command. The command previous_prime(a) returns the prime previous to $a$.
- The Factor Command. The command factor(a) returns the factorization of $a$.
- The Euler phi Function. The command euler_phi(n) returns the the number of positive integers less than or equal to $n$ that are relatively prime to $n$.