[Home]
[
prev
] [
up
] [
next
] ((test/sitools/sitools.as))
34.2
Primality Test
757a
⟨
test prime
757a
⟩
≡
(
753
)
757b
⊳
testPrime1():
()
==
{
import
from
I
,
SmallIntegerTools
;
assertTrue(prime?
2147483647);
--
previousPrime(2^31)=2^31-1
}
Uses
I
47
and
SmallIntegerTools
555
.
757b
⟨
test prime
757a
⟩
+
≡
(
753
)
⊲
757a
757c
⊳
testPrime2():
()
==
{
import
from
I
,
SmallIntegerTools
;
assertTrue(prime?
2147483629);
--
previousPrime
previousPrime(2^31)
assertEquals(
I
,
2147483647,
nextPrime
2147483629);
}
Uses
I
47
and
SmallIntegerTools
555
.
757c
⟨
test prime
757a
⟩
+
≡
(
753
)
⊲
757b
758a
⊳
testPrime3():
()
==
{
import
from
I
,
SmallIntegerTools
;
assertTrue(prime?
16777259);
--
nextPrime(2^24)
assertEquals(
I
,
16777259,
nextPrime(2^24));
}
Uses
I
47
and
SmallIntegerTools
555
.
758a
⟨
test prime
757a
⟩
+
≡
(
753
)
⊲
757c
758b
⊳
testPrime4():
()
==
{
import
from
I
,
SmallIntegerTools
;
assertEquals(
I
,
32003,
nextPrime
32000);
assertFalse(prime?
32001);
assertFalse(prime?
32002);
assertTrue
(prime?
32003);
}
Uses
I
47
and
SmallIntegerTools
555
.
758b
⟨
test prime
757a
⟩
+
≡
(
753
)
⊲
758a
758c
⊳
testPrime5():
()
==
{
import
from
I
,
SmallIntegerTools
;
assertEquals(
I
,
31991,
previousPrime
32000);
}
Uses
I
47
and
SmallIntegerTools
555
.
758c
⟨
test prime
757a
⟩
+
≡
(
753
)
⊲
758b
testPrime6():
()
==
{
import
from
I
,
SmallIntegerTools
;
assertEquals(
I
,
2081851099,
nextPrime(65003*32027));
assertTrue(prime?
2081851099);
}
Uses
I
47
and
SmallIntegerTools
555
.
[Home]
[
prev
] [
up
] [
next
] ((test/sitools/sitools.as))