|
Download math/math-0177.jsonl from winapiadmin/tinycodinglm: direct link, hf CLI and curl.
- Browser
- Download file 1.22 kB
-
https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/7fe6853bcbe998c7aec3aa0f7086f584cc091586/math/math-0177.jsonl
- Command line
-
hf download hf://datasets/winapiadmin/tinycodinglm@7fe6853bcbe998c7aec3aa0f7086f584cc091586/math/math-0177.jsonl
-
curl -L -o math-0177.jsonl https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/7fe6853bcbe998c7aec3aa0f7086f584cc091586/math/math-0177.jsonl
1.22 kB
| {"type": "session", "harness": "opencode", "id": "math-0177", "name": "Miller-Rabin Primality Test"} | |
| {"type": "message", "message": {"role": "system", "content": "You are an expert mathematician and programmer."}} | |
| {"type": "message", "message": {"role": "user", "content": "Explain Miller-Rabin primality testing"}} | |
| {"type": "message", "message": {"role": "assistant", "content": "Based on Fermat: if n prime, a^{n-1} = 1 (mod n). But Carmichael numbers fool Fermat.\n\nMiller-Rabin enhancement: write n-1 = 2^r * d. Compute a^d mod n. If result is 1 or n-1, probably prime. Otherwise square r times: if any result is n-1, probably prime. If none, composite.\n\nWhy it works: if n is prime, the only square roots of 1 mod n are +1 and -1. Finding a non-trivial square root of 1 proves compositeness.\n\nDeterministic versions with known bases:\n- n < 2,047: test a=2\n- n < 1,373,653: test a=2,3\n- n < 9,080,191: test a=31,73\n- n < 25,326,001: test a=2,3,5\n- n < 3,215,031,751: test a=2,3,5,7\n- n < 3.3e24: test a=2,3,5,7,11,13\n\nImplementation: modular exponentiation with __int128 to avoid overflow.\n\nApplications: generate random large primes for RSA, verify primality in O(k log^2 n) with k tests."}} | |