Skip to main content
Challenges Miller-Rabin and Carmichael numbers
Cryptography Hard Primality testing Solves: 6

Miller-Rabin and Carmichael numbers

Author: CyberSamSU
Points
75

In cryptography, large prime numbers are needed, but checking them by factoring is impossible. For this reason, probabilistic primality tests are used.

The simplest test is the Fermat test: if n is prime, for any a, a^(n-1) ≡ 1 (mod n). However, there are composite numbers that fool this test — they are called Carmichael numbers (the smallest is 561). Such a number passes the Fermat test for all coprime bases, but is not prime!

The Miller-Rabin test is stronger. It writes n - 1 = 2^s · d (where d is odd) and checks the sequence a^d, a^(2d), a^(4d), ...: for a prime number, the sequence either starts with 1, or at some step equals n-1. If repeated with several random bases, the probability of error practically drops to zero.

The attached sonlar.txt file contains 20 19-digit numbers. Among them, only one is a true prime number (there are also Carmichael numbers among the rest — do not limit yourself to the Fermat test). Find that prime number and assemble the flag: BAYROQ{M4TH_miller_rabin_<tub son>}

Attached files
sonlar.txt Log in to download
SHA-256 checksums
sonlar.txt: d40d919326501fd3d9b755ef6469bade6b54ce425a43dd8bfa838700ae30047a
Hints 3
Opening a hint reduces the points you get for solving this challenge.
Hint 1 −7 pts Log in
Hint 2 −15 pts Log in
Hint 3 −22 pts Log in
To submit a flag, log in.

First solvers

1. W.o.X 11.09.2026
2. Лазиз 04.10.2026
3. testrejim 09.10.2026
4. Mirjaxon Qaxxarov 26.10.2026
5. Odam 05.11.2026
6. arcanum 11.11.2026