code / tomo

Lines41.3K C23.7K Markdown9.7K YAML5.0K Tomo2.3K
7 others 763
Python231 Shell230 make212 INI47 Text21 SVG16 Lua6
(40 lines)
1 '\" t
2 .\" Copyright (c) 2026 Bruce Hill
3 .\" All rights reserved.
4 .\"
5 .TH Int.is_prime 3 2026-01-19 "Tomo man-pages"
6 .SH NAME
7 Int.is_prime \- check if an integer is prime
8 .SH LIBRARY
9 Tomo Standard Library
10 .SH SYNOPSIS
11 .nf
12 .BI Int.is_prime\ :\ func(x:\ Int,\ reps:\ Int\ =\ 50\ ->\ Bool)
13 .fi
14 .SH DESCRIPTION
15 Determines if an integer is a prime number.
18 .SH ARGUMENTS
20 .TS
21 allbox;
22 lb lb lbx lb
23 l l l l.
24 Name Type Description Default
25 x Int The integer to be checked. -
26 reps Int The number of repetitions for primality tests. 50
27 .TE
28 .SH RETURN
29 `yes` if `x` is a prime number, `no` otherwise.
31 .SH NOTES
32 This function is _probabilistic_. With the default arguments, the chances of getting an incorrect answer are astronomically small (on the order of 10^(-30)). See [the GNU MP docs](https://gmplib.org/manual/Number-Theoretic-Functions#index-mpz_005fprobab_005fprime_005fp) for more details.
34 .SH EXAMPLES
35 .EX
36 assert 7.is_prime() == yes
37 assert 6.is_prime() == no
38 .EE
39 .SH SEE ALSO
40 .BR Tomo-Int (3)