This site is supported by donations to The OEIS Foundation.

# Template:If prime

(Redirected from Template:Is prime)

The {{if prime}} if-then-else arithmetic function template returns {{{2|1}}} if {{{1}}} is prime (negative or positive) otherwise returns {{{3|0}}}.

The {{is prime}} predicate arithmetic function template returns 1 (if true) or 0 (if false.)

## Usage

{{if prime|input|output if true (optional, default: 1)|output if false (optional, default: 0)}}

or

{{is prime|input}}

## Valid input

Input must be an integer less than 1031 2 = 1062961.

## Examples

Examples with valid input (check primes with https://oeis.org/A000040/a000040.txt N. J. A. Sloane, Table of n, prime(n) for n = 1..100000)

code result
{{is prime|-5}} 1
{{is prime|-4}} 0
{{is prime|-3}} 1
{{is prime|-2}} 1
{{is prime|-1}} 0
{{is prime|0}} 0
{{is prime|1}} 0
{{is prime|2}} 1
{{is prime|3}} 1
{{is prime|4}} 0
{{is prime|5}} 1
{{if prime|6|{{yes}}|{{no}}}}
{{if prime|6|prime|not prime}} not prime
{{if prime|7|{{yes}}|{{no}}}}
{{if prime|7|prime|not prime}} prime
{{if prime|8|prime|not prime}} not prime
{{if prime|9|prime|not prime}} not prime
{{if prime|10|prime|not prime}} not prime
{{if prime|11|prime|not prime}} prime
{{if prime|12|prime|not prime}} not prime
{{if prime|13|prime|not prime}} prime
{{if prime|14|prime|not prime}} not prime
{{if prime|15|prime|not prime}} not prime
{{if prime|16|prime|not prime}} not prime
{{if prime|17|prime|not prime}} prime
{{if prime|19|prime|not prime}} prime
{{if prime|23|prime|not prime}} prime
{{if prime|29|prime|not prime}} prime
{{if prime|31|prime|not prime}} prime
{{if prime|37|prime|not prime}} prime
{{if prime|41|prime|not prime}} prime
{{if prime|199|prime|not prime}} prime
{{if prime|257|prime|not prime}} prime
{{if prime|999|prime|not prime}} not prime
{{if prime|1001|prime|not prime}} not prime
{{if prime|10001|prime|not prime}} not prime
{{if prime|10003|prime|not prime}} not prime
{{if prime|10005|prime|not prime}} not prime
{{if prime|10007|prime|not prime}} prime
{{if prime|10009|prime|not prime}} prime
{{if prime|17160|prime|not prime}} not prime
{{if prime|65536|prime|not prime}} not prime
{{if prime|65537|prime|not prime}} prime
{{if prime|65539|prime|not prime}} prime
{{if prime|65541|prime|not prime}} not prime
{{if prime|65543|prime|not prime}} prime
{{if prime|65545|prime|not prime}} not prime
{{if prime|65547|prime|not prime}} not prime
{{if prime|65549|prime|not prime}} not prime
{{if prime|65551|prime|not prime}} prime
{{if prime|65553|prime|not prime}} not prime
{{if prime|65555|prime|not prime}} not prime
{{if prime|65557|prime|not prime}} prime
{{if prime|65559|prime|not prime}} not prime
{{if prime|65561|prime|not prime}} not prime
{{if prime|65563|prime|not prime}} prime
{{if prime|65567|prime|not prime}} not prime
{{if prime|65569|prime|not prime}} not prime
{{if prime|65571|prime|not prime}} not prime
{{if prime|65573|prime|not prime}} not prime
{{if prime|65577|prime|not prime}} not prime
{{if prime|65579|prime|not prime}} prime
{{if prime|65581|prime|not prime}} prime
{{if prime|65583|prime|not prime}} not prime
{{if prime|65587|prime|not prime}} prime
{{if prime|65589|prime|not prime}} not prime
{{if prime|65591|prime|not prime}} not prime
{{if prime|65593|prime|not prime}} not prime
{{if prime|65597|prime|not prime}} not prime
{{if prime|65599|prime|not prime}} prime
{{if prime|965536|prime|not prime}} not prime
{{if prime|965537|prime|not prime}} not prime
{{if prime|965539|prime|not prime}} not prime
{{if prime|965541|prime|not prime}} not prime
{{if prime|965543|prime|not prime}} not prime
{{if prime|965545|prime|not prime}} not prime
{{if prime|965547|prime|not prime}} not prime
{{if prime|965549|prime|not prime}} not prime
{{if prime|965551|prime|not prime}} prime
{{if prime|965553|prime|not prime}} not prime
{{if prime|965555|prime|not prime}} not prime
{{if prime|965557|prime|not prime}} not prime
{{if prime|965559|prime|not prime}} not prime
{{if prime|965561|prime|not prime}} not prime
{{if prime|965563|prime|not prime}} not prime
{{if prime|965567|prime|not prime}} prime
{{if prime|965569|prime|not prime}} not prime
{{if prime|965571|prime|not prime}} not prime
{{if prime|965573|prime|not prime}} not prime
{{if prime|965577|prime|not prime}} not prime
{{if prime|965579|prime|not prime}} not prime
{{if prime|965581|prime|not prime}} not prime
{{if prime|965583|prime|not prime}} not prime
{{if prime|965587|prime|not prime}} not prime
{{if prime|965589|prime|not prime}} not prime
{{if prime|965591|prime|not prime}} not prime
{{if prime|965593|prime|not prime}} not prime
{{if prime|965597|prime|not prime}} not prime
{{if prime|965599|prime|not prime}} not prime
{{if prime|965601|prime|not prime}} not prime
{{if prime|965603|prime|not prime}} prime
{{if prime|965607|prime|not prime}} not prime
{{if prime|965609|prime|not prime}} not prime
{{if prime|965611|prime|not prime}} prime
{{if prime|965613|prime|not prime}} not prime
{{if prime|965617|prime|not prime}} not prime
{{if prime|965619|prime|not prime}} not prime
{{if prime|965621|prime|not prime}} prime
{{if prime|965623|prime|not prime}} prime
{{if prime|1021^2|prime|not prime}} not prime
{{if prime|1031^2 - 1|prime|not prime}} not prime
{{if prime|+1000|prime|not prime}} not prime
{{if prime|10.0|prime|not prime}} not prime
{{if prime|floor pi|prime|not prime}} prime
{{if prime|floor (pi^2)|prime|not prime}} not prime
{{if prime|{{Fibonacci|10}}|prime|not prime}} not prime
{{if prime|{{Fibonacci|11}}|prime|not prime}} prime

Examples with invalid input

code result
{{if prime|1031^2|prime|not prime}} If prime error: Argument must be an integer with absolute value less than 1031 2 = 1062961
{{if prime}} If prime error: Argument must be an integer
{{if prime|one}} If prime error: Argument must be an integer
{{if prime|-0.1}} If prime error: Argument must be an integer
{{if prime|0.897}} If prime error: Argument must be an integer
{{if prime|1.523}} If prime error: Argument must be an integer
{{if prime|-34.2}} If prime error: Argument must be an integer
{{if prime|pi}} If prime error: Argument must be an integer

## Formatted numbers

This template requires unformatted numbers, it will not recognize formatted numbers, e.g. comma separated, which is by design since formatted numbers will break expression parsers. To remove the formatting from a number, you can wrap the number first in {{formatnum:number|R}}.[1]

code result
{{if prime|1,000|prime|not prime}} If prime error: Argument must be an integer
{{if prime|{{formatnum:1,000|R}}|prime|not prime}} not prime

## Code

```
A000040: The prime numbers.

https://oeis.org/A000040/a000040.txt

{{list
| create
| from = b-file
| input =

1 2
2 3
3 5
4 7
5 11
6 13
7 17
8 19
9 23
10 29
11 31
12 37
13 41
14 43
15 47
16 53
17 59
18 61
19 67
20 71
21 73
22 79
23 83
24 89
25 97
26 101
27 103
28 107
29 109
30 113
31 127
32 131
33 137
34 139
35 149
36 151
37 157
38 163
39 167
40 173
41 179
42 181
43 191
44 193
45 197
46 199
47 211
48 223
49 227
50 229
51 233
52 239
53 241
54 251
55 257
56 263
57 269
58 271
59 277
60 281
61 283
62 293
63 307
64 311
65 313
66 317
67 331
68 337
69 347
70 349
71 353
72 359
73 367
74 373
75 379
76 383
77 389
78 397
79 401
80 409
81 419
82 421
83 431
84 433
85 439
86 443
87 449
88 457
89 461
90 463
91 467
92 479
93 487
94 491
95 499
96 503
97 509
98 521
99 523
100 541
101 547
102 557
103 563
104 569
105 571
106 577
107 587
108 593
109 599
110 601
111 607
112 613
113 617
114 619
115 631
116 641
117 643
118 647
119 653
120 659
121 661
122 673
123 677
124 683
125 691
126 701
127 709
128 719
129 727
130 733
131 739
132 743
133 751
134 757
135 761
136 769
137 773
138 787
139 797
140 809
141 811
142 821
143 823
144 827
145 829
146 839
147 853
148 857
149 859
150 863
151 877
152 881
153 883
154 887
155 907
156 911
157 919
158 929
159 937
160 941
161 947
162 953
163 967
164 971
165 977
166 983
167 991
168 997
169 1009
170 1013
171 1019
172 1021
173 1031

}}

gives

2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021,1031

```
```
<noinclude>{{documentation}}<!--

A000040 The prime numbers.

The 172 primes less than 2^10 = 1024 are:

n a(n)

1 2
2 3
3 5
4 7
5 11
6 13
7 17
8 19
9 23

(...)

165 977
166 983
167 991
168 997
169 1009
170 1013
171 1019
172 1021

The next prime is:

173 1031

--></noinclude><includeonly>{{ifint| {{{1|NAN}}}
| {{#ifexpr: ( abs ({{{1}}}) ) < 1031^2
| {{#ifexpr: ( abs ({{{1}}}) ) > 1
| {{#ifexpr: (

<!--

A000040 The prime numbers.

The 172 primes less than 2^10 = 1024 are:

2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021

-->

<!--   1 -->{{#ifexpr: (  2 *   2) <= abs ({{{1}}}) | abs ({{{1}}}) mod   2 | 1 }} and
<!--   2 -->{{#ifexpr: (  3 *   3) <= abs ({{{1}}}) | abs ({{{1}}}) mod   3 | 1 }} and
<!--   3 -->{{#ifexpr: (  5 *   5) <= abs ({{{1}}}) | abs ({{{1}}}) mod   5 | 1 }} and
<!--   4 -->{{#ifexpr: (  7 *   7) <= abs ({{{1}}}) | abs ({{{1}}}) mod   7 | 1 }} and

<!--   5 -->{{#ifexpr: ( 11 *  11) <= abs ({{{1}}}) | abs ({{{1}}}) mod  11 | 1 }} and
<!--   6 -->{{#ifexpr: ( 13 *  13) <= abs ({{{1}}}) | abs ({{{1}}}) mod  13 | 1 }} and
<!--   7 -->{{#ifexpr: ( 17 *  17) <= abs ({{{1}}}) | abs ({{{1}}}) mod  17 | 1 }} and
<!--   8 -->{{#ifexpr: ( 19 *  19) <= abs ({{{1}}}) | abs ({{{1}}}) mod  19 | 1 }} and

<!--   9 -->{{#ifexpr: ( 23 *  23) <= abs ({{{1}}}) | abs ({{{1}}}) mod  23 | 1 }} and
<!--  10 -->{{#ifexpr: ( 29 *  29) <= abs ({{{1}}}) | abs ({{{1}}}) mod  29 | 1 }} and

<!--  11 -->{{#ifexpr: ( 31 *  31) <= abs ({{{1}}}) | abs ({{{1}}}) mod  31 | 1 }} and
<!--  12 -->{{#ifexpr: ( 37 *  37) <= abs ({{{1}}}) | abs ({{{1}}}) mod  37 | 1 }} and

<!--  13 -->{{#ifexpr: ( 41 *  41) <= abs ({{{1}}}) | abs ({{{1}}}) mod  41 | 1 }} and
<!--  14 -->{{#ifexpr: ( 43 *  43) <= abs ({{{1}}}) | abs ({{{1}}}) mod  43 | 1 }} and
<!--  15 -->{{#ifexpr: ( 47 *  47) <= abs ({{{1}}}) | abs ({{{1}}}) mod  47 | 1 }} and

<!--  16 -->{{#ifexpr: ( 53 *  53) <= abs ({{{1}}}) | abs ({{{1}}}) mod  53 | 1 }} and
<!--  17 -->{{#ifexpr: ( 59 *  59) <= abs ({{{1}}}) | abs ({{{1}}}) mod  59 | 1 }} and

<!--  18 -->{{#ifexpr: ( 61 *  61) <= abs ({{{1}}}) | abs ({{{1}}}) mod  61 | 1 }} and
<!--  19 -->{{#ifexpr: ( 67 *  67) <= abs ({{{1}}}) | abs ({{{1}}}) mod  67 | 1 }} and

<!--  20 -->{{#ifexpr: ( 71 *  71) <= abs ({{{1}}}) | abs ({{{1}}}) mod  71 | 1 }} and
<!--  21 -->{{#ifexpr: ( 73 *  73) <= abs ({{{1}}}) | abs ({{{1}}}) mod  73 | 1 }} and
<!--  22 -->{{#ifexpr: ( 79 *  79) <= abs ({{{1}}}) | abs ({{{1}}}) mod  79 | 1 }} and

<!--  23 -->{{#ifexpr: ( 83 *  83) <= abs ({{{1}}}) | abs ({{{1}}}) mod  83 | 1 }} and
<!--  24 -->{{#ifexpr: ( 89 *  89) <= abs ({{{1}}}) | abs ({{{1}}}) mod  89 | 1 }} and

<!--  25 -->{{#ifexpr: ( 97 *  97) <= abs ({{{1}}}) | abs ({{{1}}}) mod  97 | 1 }} and

<!--  26 -->{{#ifexpr: (101 * 101) <= abs ({{{1}}}) | abs ({{{1}}}) mod 101 | 1 }} and
<!--  27 -->{{#ifexpr: (103 * 103) <= abs ({{{1}}}) | abs ({{{1}}}) mod 103 | 1 }} and
<!--  28 -->{{#ifexpr: (107 * 107) <= abs ({{{1}}}) | abs ({{{1}}}) mod 107 | 1 }} and
<!--  29 -->{{#ifexpr: (109 * 109) <= abs ({{{1}}}) | abs ({{{1}}}) mod 109 | 1 }} and

<!--  30 -->{{#ifexpr: (113 * 113) <= abs ({{{1}}}) | abs ({{{1}}}) mod 113 | 1 }} and

<!--  31 -->{{#ifexpr: (127 * 127) <= abs ({{{1}}}) | abs ({{{1}}}) mod 127 | 1 }}

{{#ifexpr: (131 * 131) <=  abs ({{{1}}}) | and

<!--  32 -->{{#ifexpr: (131 * 131) <= abs ({{{1}}}) | abs ({{{1}}}) mod 131 | 1 }} and
<!--  33 -->{{#ifexpr: (137 * 137) <= abs ({{{1}}}) | abs ({{{1}}}) mod 137 | 1 }} and
<!--  34 -->{{#ifexpr: (139 * 139) <= abs ({{{1}}}) | abs ({{{1}}}) mod 139 | 1 }} and

<!--  35 -->{{#ifexpr: (149 * 149) <= abs ({{{1}}}) | abs ({{{1}}}) mod 149 | 1 }} and

<!--  36 -->{{#ifexpr: (151 * 151) <= abs ({{{1}}}) | abs ({{{1}}}) mod 151 | 1 }} and
<!--  37 -->{{#ifexpr: (157 * 157) <= abs ({{{1}}}) | abs ({{{1}}}) mod 157 | 1 }} and

<!--  38 -->{{#ifexpr: (163 * 163) <= abs ({{{1}}}) | abs ({{{1}}}) mod 163 | 1 }} and
<!--  39 -->{{#ifexpr: (167 * 167) <= abs ({{{1}}}) | abs ({{{1}}}) mod 167 | 1 }} and

<!--  40 -->{{#ifexpr: (173 * 173) <= abs ({{{1}}}) | abs ({{{1}}}) mod 173 | 1 }} and
<!--  41 -->{{#ifexpr: (179 * 179) <= abs ({{{1}}}) | abs ({{{1}}}) mod 179 | 1 }} and

<!--  42 -->{{#ifexpr: (181 * 181) <= abs ({{{1}}}) | abs ({{{1}}}) mod 181 | 1 }} and

<!--  43 -->{{#ifexpr: (191 * 191) <= abs ({{{1}}}) | abs ({{{1}}}) mod 191 | 1 }} and
<!--  44 -->{{#ifexpr: (193 * 193) <= abs ({{{1}}}) | abs ({{{1}}}) mod 193 | 1 }} and
<!--  45 -->{{#ifexpr: (197 * 197) <= abs ({{{1}}}) | abs ({{{1}}}) mod 197 | 1 }} and
<!--  46 -->{{#ifexpr: (199 * 199) <= abs ({{{1}}}) | abs ({{{1}}}) mod 199 | 1 }} and

<!--  47 -->{{#ifexpr: (211 * 211) <= abs ({{{1}}}) | abs ({{{1}}}) mod 211 | 1 }} and

<!--  48 -->{{#ifexpr: (223 * 223) <= abs ({{{1}}}) | abs ({{{1}}}) mod 223 | 1 }} and
<!--  49 -->{{#ifexpr: (227 * 227) <= abs ({{{1}}}) | abs ({{{1}}}) mod 227 | 1 }} and
<!--  50 -->{{#ifexpr: (229 * 229) <= abs ({{{1}}}) | abs ({{{1}}}) mod 229 | 1 }} and

<!--  51 -->{{#ifexpr: (233 * 233) <= abs ({{{1}}}) | abs ({{{1}}}) mod 233 | 1 }} and
<!--  52 -->{{#ifexpr: (239 * 239) <= abs ({{{1}}}) | abs ({{{1}}}) mod 239 | 1 }} and

<!--  53 -->{{#ifexpr: (241 * 241) <= abs ({{{1}}}) | abs ({{{1}}}) mod 241 | 1 }} and

<!--  54 -->{{#ifexpr: (251 * 251) <= abs ({{{1}}}) | abs ({{{1}}}) mod 251 | 1 }}

}}

<!--

A000040 The prime numbers.

The 172 primes less than 2^10 = 1024 are:

2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021

-->

{{#ifexpr: (257 * 257) <=  abs ({{{1}}}) | and

<!--  55 -->{{#ifexpr: (257 * 257) <= abs ({{{1}}}) | abs ({{{1}}}) mod 257 | 1 }} and

<!--  56 -->{{#ifexpr: (263 * 263) <= abs ({{{1}}}) | abs ({{{1}}}) mod 263 | 1 }} and
<!--  57 -->{{#ifexpr: (269 * 269) <= abs ({{{1}}}) | abs ({{{1}}}) mod 269 | 1 }} and

<!--  58 -->{{#ifexpr: (271 * 271) <= abs ({{{1}}}) | abs ({{{1}}}) mod 271 | 1 }} and
<!--  59 -->{{#ifexpr: (277 * 277) <= abs ({{{1}}}) | abs ({{{1}}}) mod 277 | 1 }} and

<!--  60 -->{{#ifexpr: (281 * 281) <= abs ({{{1}}}) | abs ({{{1}}}) mod 281 | 1 }} and
<!--  61 -->{{#ifexpr: (283 * 283) <= abs ({{{1}}}) | abs ({{{1}}}) mod 283 | 1 }} and

<!--  62 -->{{#ifexpr: (293 * 293) <= abs ({{{1}}}) | abs ({{{1}}}) mod 293 | 1 }} and

<!--  63 -->{{#ifexpr: (307 * 307) <= abs ({{{1}}}) | abs ({{{1}}}) mod 307 | 1 }} and

<!--  64 -->{{#ifexpr: (311 * 311) <= abs ({{{1}}}) | abs ({{{1}}}) mod 311 | 1 }} and
<!--  65 -->{{#ifexpr: (313 * 313) <= abs ({{{1}}}) | abs ({{{1}}}) mod 313 | 1 }} and
<!--  66 -->{{#ifexpr: (317 * 317) <= abs ({{{1}}}) | abs ({{{1}}}) mod 317 | 1 }} and

<!--  67 -->{{#ifexpr: (331 * 331) <= abs ({{{1}}}) | abs ({{{1}}}) mod 331 | 1 }} and
<!--  68 -->{{#ifexpr: (337 * 337) <= abs ({{{1}}}) | abs ({{{1}}}) mod 337 | 1 }} and

<!--  69 -->{{#ifexpr: (347 * 347) <= abs ({{{1}}}) | abs ({{{1}}}) mod 347 | 1 }} and
<!--  70 -->{{#ifexpr: (349 * 349) <= abs ({{{1}}}) | abs ({{{1}}}) mod 349 | 1 }} and

<!--  71 -->{{#ifexpr: (353 * 353) <= abs ({{{1}}}) | abs ({{{1}}}) mod 353 | 1 }} and
<!--  72 -->{{#ifexpr: (359 * 359) <= abs ({{{1}}}) | abs ({{{1}}}) mod 359 | 1 }} and

<!--  73 -->{{#ifexpr: (367 * 367) <= abs ({{{1}}}) | abs ({{{1}}}) mod 367 | 1 }} and

<!--  74 -->{{#ifexpr: (373 * 373) <= abs ({{{1}}}) | abs ({{{1}}}) mod 373 | 1 }} and
<!--  75 -->{{#ifexpr: (379 * 379) <= abs ({{{1}}}) | abs ({{{1}}}) mod 379 | 1 }} and

<!--  76 -->{{#ifexpr: (383 * 383) <= abs ({{{1}}}) | abs ({{{1}}}) mod 383 | 1 }} and
<!--  77 -->{{#ifexpr: (389 * 389) <= abs ({{{1}}}) | abs ({{{1}}}) mod 389 | 1 }} and

<!--  78 -->{{#ifexpr: (397 * 397) <= abs ({{{1}}}) | abs ({{{1}}}) mod 397 | 1 }} and

<!--  79 -->{{#ifexpr: (401 * 401) <= abs ({{{1}}}) | abs ({{{1}}}) mod 401 | 1 }} and
<!--  80 -->{{#ifexpr: (409 * 409) <= abs ({{{1}}}) | abs ({{{1}}}) mod 409 | 1 }} and

<!--  81 -->{{#ifexpr: (419 * 419) <= abs ({{{1}}}) | abs ({{{1}}}) mod 419 | 1 }} and

<!--  82 -->{{#ifexpr: (421 * 421) <= abs ({{{1}}}) | abs ({{{1}}}) mod 421 | 1 }} and

<!--  83 -->{{#ifexpr: (431 * 431) <= abs ({{{1}}}) | abs ({{{1}}}) mod 431 | 1 }} and
<!--  84 -->{{#ifexpr: (433 * 433) <= abs ({{{1}}}) | abs ({{{1}}}) mod 433 | 1 }} and
<!--  85 -->{{#ifexpr: (439 * 439) <= abs ({{{1}}}) | abs ({{{1}}}) mod 439 | 1 }} and

<!--  86 -->{{#ifexpr: (443 * 443) <= abs ({{{1}}}) | abs ({{{1}}}) mod 443 | 1 }} and
<!--  87 -->{{#ifexpr: (449 * 449) <= abs ({{{1}}}) | abs ({{{1}}}) mod 449 | 1 }} and

<!--  88 -->{{#ifexpr: (457 * 457) <= abs ({{{1}}}) | abs ({{{1}}}) mod 457 | 1 }} and

<!--  89 -->{{#ifexpr: (461 * 461) <= abs ({{{1}}}) | abs ({{{1}}}) mod 461 | 1 }} and
<!--  90 -->{{#ifexpr: (463 * 463) <= abs ({{{1}}}) | abs ({{{1}}}) mod 463 | 1 }} and
<!--  91 -->{{#ifexpr: (467 * 467) <= abs ({{{1}}}) | abs ({{{1}}}) mod 467 | 1 }} and

<!--  92 -->{{#ifexpr: (479 * 479) <= abs ({{{1}}}) | abs ({{{1}}}) mod 479 | 1 }} and

<!--  93 -->{{#ifexpr: (487 * 487) <= abs ({{{1}}}) | abs ({{{1}}}) mod 487 | 1 }} and

<!--  94 -->{{#ifexpr: (491 * 491) <= abs ({{{1}}}) | abs ({{{1}}}) mod 491 | 1 }} and
<!--  95 -->{{#ifexpr: (499 * 499) <= abs ({{{1}}}) | abs ({{{1}}}) mod 499 | 1 }} and

<!--  96 -->{{#ifexpr: (503 * 503) <= abs ({{{1}}}) | abs ({{{1}}}) mod 503 | 1 }} and
<!--  97 -->{{#ifexpr: (509 * 509) <= abs ({{{1}}}) | abs ({{{1}}}) mod 509 | 1 }}

}}

<!--

A000040 The prime numbers.

The 172 primes less than 2^10 = 1024 are:

2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021

-->

{{#ifexpr: (521 * 521) <=  abs ({{{1}}}) | and

<!--  98 -->{{#ifexpr: (521 * 521) <= abs ({{{1}}}) | abs ({{{1}}}) mod 521 | 1 }} and
<!--  99 -->{{#ifexpr: (523 * 523) <= abs ({{{1}}}) | abs ({{{1}}}) mod 523 | 1 }} and

<!-- 100 -->{{#ifexpr: (541 * 541) <= abs ({{{1}}}) | abs ({{{1}}}) mod 541 | 1 }} and
<!-- 101 -->{{#ifexpr: (547 * 547) <= abs ({{{1}}}) | abs ({{{1}}}) mod 547 | 1 }} and

<!-- 102 -->{{#ifexpr: (557 * 557) <= abs ({{{1}}}) | abs ({{{1}}}) mod 557 | 1 }} and

<!-- 103 -->{{#ifexpr: (563 * 563) <= abs ({{{1}}}) | abs ({{{1}}}) mod 563 | 1 }} and
<!-- 104 -->{{#ifexpr: (569 * 569) <= abs ({{{1}}}) | abs ({{{1}}}) mod 569 | 1 }} and

<!-- 105 -->{{#ifexpr: (571 * 571) <= abs ({{{1}}}) | abs ({{{1}}}) mod 571 | 1 }} and
<!-- 106 -->{{#ifexpr: (577 * 577) <= abs ({{{1}}}) | abs ({{{1}}}) mod 577 | 1 }} and

<!-- 107 -->{{#ifexpr: (587 * 587) <= abs ({{{1}}}) | abs ({{{1}}}) mod 587 | 1 }} and

<!-- 108 -->{{#ifexpr: (593 * 593) <= abs ({{{1}}}) | abs ({{{1}}}) mod 593 | 1 }} and
<!-- 109 -->{{#ifexpr: (599 * 599) <= abs ({{{1}}}) | abs ({{{1}}}) mod 599 | 1 }} and

<!-- 110 -->{{#ifexpr: (601 * 601) <= abs ({{{1}}}) | abs ({{{1}}}) mod 601 | 1 }} and
<!-- 111 -->{{#ifexpr: (607 * 607) <= abs ({{{1}}}) | abs ({{{1}}}) mod 607 | 1 }} and

<!-- 112 -->{{#ifexpr: (613 * 613) <= abs ({{{1}}}) | abs ({{{1}}}) mod 613 | 1 }} and
<!-- 113 -->{{#ifexpr: (617 * 617) <= abs ({{{1}}}) | abs ({{{1}}}) mod 617 | 1 }} and
<!-- 114 -->{{#ifexpr: (619 * 619) <= abs ({{{1}}}) | abs ({{{1}}}) mod 619 | 1 }} and

<!-- 115 -->{{#ifexpr: (631 * 631) <= abs ({{{1}}}) | abs ({{{1}}}) mod 631 | 1 }} and

<!-- 116 -->{{#ifexpr: (641 * 641) <= abs ({{{1}}}) | abs ({{{1}}}) mod 641 | 1 }} and
<!-- 117 -->{{#ifexpr: (643 * 643) <= abs ({{{1}}}) | abs ({{{1}}}) mod 643 | 1 }} and
<!-- 118 -->{{#ifexpr: (647 * 647) <= abs ({{{1}}}) | abs ({{{1}}}) mod 647 | 1 }} and

<!-- 119 -->{{#ifexpr: (653 * 653) <= abs ({{{1}}}) | abs ({{{1}}}) mod 653 | 1 }} and
<!-- 120 -->{{#ifexpr: (659 * 659) <= abs ({{{1}}}) | abs ({{{1}}}) mod 659 | 1 }} and

<!-- 121 -->{{#ifexpr: (661 * 661) <= abs ({{{1}}}) | abs ({{{1}}}) mod 661 | 1 }} and

<!-- 122 -->{{#ifexpr: (673 * 673) <= abs ({{{1}}}) | abs ({{{1}}}) mod 673 | 1 }} and
<!-- 123 -->{{#ifexpr: (677 * 677) <= abs ({{{1}}}) | abs ({{{1}}}) mod 677 | 1 }} and

<!-- 124 -->{{#ifexpr: (683 * 683) <= abs ({{{1}}}) | abs ({{{1}}}) mod 683 | 1 }} and

<!-- 125 -->{{#ifexpr: (691 * 691) <= abs ({{{1}}}) | abs ({{{1}}}) mod 691 | 1 }} and

<!-- 126 -->{{#ifexpr: (701 * 701) <= abs ({{{1}}}) | abs ({{{1}}}) mod 701 | 1 }} and
<!-- 127 -->{{#ifexpr: (709 * 709) <= abs ({{{1}}}) | abs ({{{1}}}) mod 709 | 1 }} and

<!-- 128 -->{{#ifexpr: (719 * 719) <= abs ({{{1}}}) | abs ({{{1}}}) mod 719 | 1 }} and

<!-- 129 -->{{#ifexpr: (727 * 727) <= abs ({{{1}}}) | abs ({{{1}}}) mod 727 | 1 }} and

<!-- 130 -->{{#ifexpr: (733 * 733) <= abs ({{{1}}}) | abs ({{{1}}}) mod 733 | 1 }} and
<!-- 131 -->{{#ifexpr: (739 * 739) <= abs ({{{1}}}) | abs ({{{1}}}) mod 739 | 1 }} and

<!-- 132 -->{{#ifexpr: (743 * 743) <= abs ({{{1}}}) | abs ({{{1}}}) mod 743 | 1 }} and

<!-- 133 -->{{#ifexpr: (751 * 751) <= abs ({{{1}}}) | abs ({{{1}}}) mod 751 | 1 }} and
<!-- 134 -->{{#ifexpr: (757 * 757) <= abs ({{{1}}}) | abs ({{{1}}}) mod 757 | 1 }} and

<!-- 135 -->{{#ifexpr: (761 * 761) <= abs ({{{1}}}) | abs ({{{1}}}) mod 761 | 1 }}

}}

<!--

A000040 The prime numbers.

The 172 primes less than 2^10 = 1024 are:

2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021

-->

{{#ifexpr: (769 * 769) <=  abs ({{{1}}}) | and

<!-- 136 -->{{#ifexpr: (769 * 769) <= abs ({{{1}}}) | abs ({{{1}}}) mod 769 | 1 }} and

<!-- 137 -->{{#ifexpr: (773 * 773) <= abs ({{{1}}}) | abs ({{{1}}}) mod 773 | 1 }} and

<!-- 138 -->{{#ifexpr: (787 * 787) <= abs ({{{1}}}) | abs ({{{1}}}) mod 787 | 1 }} and

<!-- 139 -->{{#ifexpr: (797 * 797) <= abs ({{{1}}}) | abs ({{{1}}}) mod 797 | 1 }} and

<!-- 140 -->{{#ifexpr: (809 * 809) <= abs ({{{1}}}) | abs ({{{1}}}) mod 809 | 1 }} and

<!-- 141 -->{{#ifexpr: (811 * 811) <= abs ({{{1}}}) | abs ({{{1}}}) mod 811 | 1 }} and

<!-- 142 -->{{#ifexpr: (821 * 821) <= abs ({{{1}}}) | abs ({{{1}}}) mod 821 | 1 }} and
<!-- 143 -->{{#ifexpr: (823 * 823) <= abs ({{{1}}}) | abs ({{{1}}}) mod 823 | 1 }} and
<!-- 144 -->{{#ifexpr: (827 * 827) <= abs ({{{1}}}) | abs ({{{1}}}) mod 827 | 1 }} and
<!-- 145 -->{{#ifexpr: (829 * 829) <= abs ({{{1}}}) | abs ({{{1}}}) mod 829 | 1 }} and

<!-- 146 -->{{#ifexpr: (839 * 839) <= abs ({{{1}}}) | abs ({{{1}}}) mod 839 | 1 }} and

<!-- 147 -->{{#ifexpr: (853 * 853) <= abs ({{{1}}}) | abs ({{{1}}}) mod 853 | 1 }} and
<!-- 148 -->{{#ifexpr: (857 * 857) <= abs ({{{1}}}) | abs ({{{1}}}) mod 857 | 1 }} and
<!-- 149 -->{{#ifexpr: (859 * 859) <= abs ({{{1}}}) | abs ({{{1}}}) mod 859 | 1 }} and

<!-- 150 -->{{#ifexpr: (863 * 863) <= abs ({{{1}}}) | abs ({{{1}}}) mod 863 | 1 }} and

<!-- 151 -->{{#ifexpr: (877 * 877) <= abs ({{{1}}}) | abs ({{{1}}}) mod 877 | 1 }} and

<!-- 152 -->{{#ifexpr: (881 * 881) <= abs ({{{1}}}) | abs ({{{1}}}) mod 881 | 1 }} and
<!-- 153 -->{{#ifexpr: (883 * 883) <= abs ({{{1}}}) | abs ({{{1}}}) mod 883 | 1 }} and
<!-- 154 -->{{#ifexpr: (887 * 887) <= abs ({{{1}}}) | abs ({{{1}}}) mod 887 | 1 }} and

<!-- 155 -->{{#ifexpr: (907 * 907) <= abs ({{{1}}}) | abs ({{{1}}}) mod 907 | 1 }} and

<!-- 156 -->{{#ifexpr: (911 * 911) <= abs ({{{1}}}) | abs ({{{1}}}) mod 911 | 1 }} and
<!-- 157 -->{{#ifexpr: (919 * 919) <= abs ({{{1}}}) | abs ({{{1}}}) mod 919 | 1 }} and

<!-- 158 -->{{#ifexpr: (929 * 929) <= abs ({{{1}}}) | abs ({{{1}}}) mod 929 | 1 }} and

<!-- 159 -->{{#ifexpr: (937 * 937) <= abs ({{{1}}}) | abs ({{{1}}}) mod 937 | 1 }} and

<!-- 160 -->{{#ifexpr: (941 * 941) <= abs ({{{1}}}) | abs ({{{1}}}) mod 941 | 1 }} and
<!-- 161 -->{{#ifexpr: (947 * 947) <= abs ({{{1}}}) | abs ({{{1}}}) mod 947 | 1 }} and

<!-- 162 -->{{#ifexpr: (953 * 953) <= abs ({{{1}}}) | abs ({{{1}}}) mod 953 | 1 }} and

<!-- 163 -->{{#ifexpr: (967 * 967) <= abs ({{{1}}}) | abs ({{{1}}}) mod 967 | 1 }} and

<!-- 164 -->{{#ifexpr: (971 * 971) <= abs ({{{1}}}) | abs ({{{1}}}) mod 971 | 1 }} and
<!-- 165 -->{{#ifexpr: (977 * 977) <= abs ({{{1}}}) | abs ({{{1}}}) mod 977 | 1 }} and

<!-- 166 -->{{#ifexpr: (983 * 983) <= abs ({{{1}}}) | abs ({{{1}}}) mod 983 | 1 }} and

<!-- 167 -->{{#ifexpr: (991 * 991) <= abs ({{{1}}}) | abs ({{{1}}}) mod 991 | 1 }} and
<!-- 168 -->{{#ifexpr: (997 * 997) <= abs ({{{1}}}) | abs ({{{1}}}) mod 997 | 1 }} and

<!-- 169 -->{{#ifexpr: (1009 * 1009) <= abs ({{{1}}}) | abs ({{{1}}}) mod 1009 | 1 }} and

<!-- 170 -->{{#ifexpr: (1013 * 1013) <= abs ({{{1}}}) | abs ({{{1}}}) mod 1013 | 1 }} and
<!-- 171 -->{{#ifexpr: (1019 * 1019) <= abs ({{{1}}}) | abs ({{{1}}}) mod 1019 | 1 }} and

<!-- 172 -->{{#ifexpr: (1021 * 1021) <= abs ({{{1}}}) | abs ({{{1}}}) mod 1021 | 1 }}

<!--

The code now allows to check the primality of any number < 1031^2 (and in particular of any number < 2^20.)

Going any further with this primitive method is just too impractical using Mediawiki templates.

-->

}}

) = 1
| {{{2|1}}}
| {{{3|0}}}
}}
| {{{3|0}}}
}}
| {{error| If prime error: Argument must be an integer with absolute value less than 1031{{^|2}} {{=}} {{#expr: 1031^2}} }}
}}
| {{error| If prime error: Argument must be an integer }}
}}</includeonly>

```