I. Equations, inequalities and expressions
14. Divisibility and primes
The app factors a whole number on its own into primes – it divides by the smallest primes one after another and writes 360 = 2³·3²·5; for a prime it shows that no prime up to its square root divides it. You can also write the test as isprime(97).
The greatest common divisor gcd(60, 90) and the least common multiple lcm(18, 30) come from the prime factorizations, or with the “Euclidean algorithm” chip by division with a remainder. The extended Euclidean algorithm with its table gives Bézout’s identity bezout(240, 46): gcd(240, 46) = 240·u + 46·v.
A number's divisors divisors(36) come in pairs 1·36, 2·18, … up to the square root, their count checked by the factorization. The divisibility rules divisibility(1236) form a table for 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 and 25 (the last digit, the digit sum, the alternating sum…); one divisor is written divisibility(1236, 7), as the sentence “is 1236 divisible by 7” or 7 | 1236 – a divisor without a school rule is divided with a remainder. The primes up to 200 come from the sieve of Eratosthenes (“primes up to 50”). A linear equation ax + by = c in the integers (“3x + 5y = 1, x, y ∈ ℤ” or the ℤ chip) is solved by Bézout's identity – all the solutions x = x₀ + 5k, y = y₀ − 3k.
Modular arithmetic: the remainder 17 mod 5, the inverse 3^(-1) mod 11 (from the extended Euclidean algorithm, with a check) and the power 7^13 mod 13 by repeated squaring. RSA is built on them – rsa(p = 11, q = 13, e = 7, m = 9) computes n, φ(n), the private key d, then encrypts the message and decrypts it again; e and m may be left out.
How to enter it
360, factor(360), isprime(97) | The prime factorization, a primality test. |
gcd(60, 90), lcm(18, 30) | The greatest common divisor and the least common multiple. |
divisors(36), divisibility(1236), divisibility(1236, 7) | A number's divisors and the divisibility rules – all, or one divisor (also the sentence “is 1236 divisible by 7”, 7 | 1236). |
primes up to 50 | The primes up to n (at most 200) by the sieve of Eratosthenes; also primes(50). |
3x + 5y = 1, x, y ∈ ℤ | A linear equation in the integers (Diophantine); also diophantine(3, 5, 1). |
bezout(240, 46) | Bézout’s identity. |
17 mod 5, 3^(-1) mod 11, 7^13 mod 13 | The remainder, the inverse and the power modulo n. |
rsa(p = 11, q = 13, e = 7, m = 9) | RSA with small numbers. |
Examples
360
97
gcd(60, 90)
lcm(60, 90) Euclidean algorithm
dělitelé(36)
dělitelnost(1236)
dělitelnost(1309, 7)
prvočísla do 50
bezout(240, 46)
3x + 5y = 1, x, y ∈ ℤ
7^13 mod 13
rsa(p = 11, q = 13, e = 7, m = 9)


Known limitations
- Prime factorization works for numbers up to 10¹⁸; a larger prime is only confirmed by a test.
- RSA is a school example with small numbers (n = p·q up to about a trillion), not real encryption.