0% found this document useful (0 votes)
6 views

A Simple Algorithm For Prime Factorizati

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

A Simple Algorithm For Prime Factorizati

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Hindawi

Journal of Mathematics
Volume 2022, Article ID 7034529, 10 pages
https://doi.org/10.1155/2022/7034529

Research Article
A Simple Algorithm for Prime Factorization and Primality Testing

1,2
Kabenge Hamiss
1
Department of Mathematics and Statistics, Islamic University in Uganda, Mbale 2555, Uganda
2
Department of Mathematical and Computer Sciences, University of Gezira, Wad Medani 20, Sudan

Correspondence should be addressed to Kabenge Hamiss; [email protected]

Received 1 September 2022; Revised 31 October 2022; Accepted 7 November 2022; Published 15 December 2022

Academic Editor: Niansheng Tang

Copyright © 2022 Kabenge Hamiss. Tis is an open access article distributed under the Creative Commons Attribution License,
which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

We propose a new simple and faster algorithm to factor numbers based on the nature of the prime numbers contained in such composite
numbers. It is well known that every composite number has a unique representation as a product of prime numbers. In this study, we focus
mainly on composite numbers that contain a product of prime numbers that are greater than or equal to 5 which are of the form 6k + 1 or
6k + 5. Terefore, we use the condition that every prime or composite P of primes greater than or equal to 5 satisfes P2 ≡ 1 (mod24).
Tis algorithm is very fast especially when the diference in the prime components of a composite number (prime gap) is not so large.
When the diference between the factors (prime gap) is not so large, it often requires just a single iteration to obtain the factors.

1. Introduction factorization algorithm, general•purpose, Special Generic


Factorizations, Williams’ P + 1 Method, and Lenstra’s El•
An integer p is prime if p ≥ 2 and has exactly two positive liptic Curve Method, among others [2, 22, 26–30].
divisors, namely, 1 and p itself [1–5]. An integer n is called a
composite if n ≥ 2 and n have more than two positive divisors 1.1. Congruences. We say that a divides b if there is some
[6–9]. integer c such that b � ac. If a divides b, we write a ∣ b, and if
Any composite number (integer) can be decomposed a does not divide b we write a∤b.
into smaller integers called prime factors, for which their If m|(a − b), we write
multiplication produces the original integer. Te process of
a ≡ b (mod m), (1)
decomposing such numbers is called integer factorization
[7, 10–12]. and say that a is congruent to b modulo m. Te quantity m is
Over the years, the prime factorization of large numbers called the modulus and all numbers congruent (or equiv•
has drawn much attention due to its practical applications alent) to a (mod m) are said to constitute a congruence (or
and the associated challenges [13, 14]. In computing ap• equivalence) class [7, 31–33]. According to [34], an algo•
plications, encryption algorithms such as the Rivest– rithm is a precise step•by•step series of rules that leads to a
Shamir–Adleman (RSA) cryptosystems are widely used for product or to the solution to a problem. Some steps in an
information security, where the keys (public and private) of algorithm depend on what happened or was learned in
the encryption code are represented using large prime earlier steps.
factors [15–21]. Since prime factorization of large numbers is
extremely hard, RSA cryptosystems take advantage of this 2. The Main Result
property to ensure information security [10, 22, 23].
Many eforts have been made to develop an efective Let p and q be prime numbers greater than or equal to 5.
method of factoring numbers and to know whether a Porras Ferreira and Willian De Jesus [35] proved that prime
number is prime or not [24, 25]. Tey include Sieve of numbers p and q are representatives of 5 (mod6) or
Eratosthenes, Pollard’s Algorithm, special•purpose 1 (mod6) implying
2 Journal of Mathematics

p ≡ 5 (mod6), Let 6rt + (r + t) � k be an integer. Ten,


(2)
q ≡ 1 (mod6). m � 6k + 1. (10)

Ten, for some integers t and r,


Case 2. Let m be a composite of at least two primes of the
p � 6t + 5,
(3) form 6t + 5 and 6r + 5; that is, m � (6t + 5)(6r + 5):
q � 6r + 1.
m � 36tr + 30(r + t) + 25,
(11)
Now, as it was earlier proven by Porras Ferreira and m � 6[6tr + 5(r + t) + 4] + 1.
Willian De Jesus [35] that if m is a composite of primes
greater or equal to 5, then m2 ≡ 1 (mod6). Let n � 6tr + 5(r + t) + 4 an integer. Ten,
m � 6n + 1. (12)
Theorem 1. Let m be a composite containing at least one
prime s < 5; then,
m2 ≡ s2k (mod24), (4) 2.2. Composite of the Form 6k + 5. Let m be a composite of at
least two primes of the form 6t + 5 and 6r + 1; that is, m �
where k is a positive integer. (6t + 5)(6r + 1):
m � 36tr + 6t + 30r + 5,
Proof. Let pi (where i � 1, 2, ..., n) be primes greater or equal (13)
to 5 and s be a prime less than 5 such that m � 6[6tr +(5r + t)] + 5.
k k k
m � sk p11 p22 . . . pnn be a composite of primes.
Since k and ki are positive integers, then Let k � 6tr + (5r + t) an integer. Ten,

p1 1 ≡ 1 (mod24),
2k m � 6k + 5. (14)

p2 2 ≡ 1 (mod24), . . . ,
2k Equations (10), (12), and (14) really show that not all
(5)
numbers of the form 6k + 1 or 6k + 5 are primes. Some of
n ≡ 1 (mod24).
p2kn
which are pseudoprimes and others just ordinary odd
numbers.
From the property in [7] of multiplication, then mul• As we can observe from the above mentioned equations,
tiplying p2i in (5) together, we obtain the values of r and t will determine whether the number is
prime or not a prime.
n ≡ 1 (mod24).
2k 2k
p1 1 p2 2 . . . p2k n (6)
We also observe that it is difcult to distinguish between
Multiplying s2k both side in (6), we obtain composites of the form (6t + 1)(6r + 1) and (6t + 5)(6r + 5)
because they both give the same result, that is, 6k + 1.
n ≡ s (mod24).
2k 2k
s2k p1 1 p2 2 . . . p2k n 2k
(7)
2k 2k 2kn
However, m2 � s2k p1 1 p2 2 . . . pn implying 2.3. Composites of the Form 6k + 1 and Teir Factorization
m2 ≡ s2k (mod24). (8) Case 3. P � (6t + 1)(6r + 1).
Tus, the theorem is proven.
Tis indicates that any composite number that contains Theorem 2. Let
at least one prime less than 5 does not satisfy the condition of P � (6t + 1)(6r + 1). (15)
1 (mod24).
Terefore, from this point, we can analyze the conditions Ten, there exists some integer A such that
that will determine any integer to be a prime or a
A ≡ (r + t) (mod6). (16)
composite. □

Proof. From
2.1. Composite of the Form 6k + 1. As stated earlier, not all P � (6t + 1)(6r + 1) � 6[6tr +(r + t)] + 1. (17)
numbers of the form 6k + 1 are primes, now, we prove to
back up the statement. Ten,
P − 1 � 6[6tr + (r + t)]. (18)
Case 1. Let m be a composite of at least two prime say of the
form 6t + 1 and 6r + 1, that is, m � (6t + 1)(6r + 1): Dividing through by 6, we obtain
m � 36tr + 6(r + t) + 1, P− 1
(9) � (r + t) + 6rt. (19)
m � 6[6rt +(r + t)] + 1. 6
Journal of Mathematics 3

Now, let A � (P − 1/6) and u � rt implying that 20 2.4. Factorizing the Composite of Case 3. Suppose P � (6t +
becomes 1)(6r + 1) is a composite with at least two prime factors;
then, there exists some positive integer A such that A ≡ t +
A � (r + t) + 6u. (20)
r (mod6) as in (17). Let
Hence, we obtain t + r � ao + 6f, (27)
A ≡ (r + t) (mod6). (21)
□ such that A − ao is divisible by 6, where f � 0, 1, 2, . . . , n
and ao is the smallest positive residue. Ten,
Lemma 1. If r + t � A, then either r � A, t � 0 or r � 0, t � rt � B − f, (28)
A is a solution (trivial solution) to (16).
where B � (A − ao /6).
From (28) and (29), we obtain
Proof. Let r + t � A. We know that u � tr � 0. Ten, it
implies that r � A − t: t2 − ao + 6f􏼁t +(B − f) � 0. (29)

t(A − t) � 0. (22) Since we are interested in the positive integer solution,


then
Tus, t � 0 or t � A.
ao + 6f􏼁 − 4(B − f) ≥ 0.
2
When t � 0, r � A or when t � A, r � 0, therefore, A (30)
and 0 is the trivial solution to (16). □
By expanding, we obtain

Corollary 1. Let P be a number of the form 6k + 1 for any 36f2 + 12ao + 4􏼁f − 4B + a2o ≥ 0. (31)
integer k ≥ 1; then, for some P is a prime, if and only if A � k
and 0 (trivial solution) is the only solution to (16). Ten, let h be the least positive integer solution for f
satisfying (32). Ten, fn � h + n, where n � 0, 1, . . . , η. Tis
implies that fmin � h for the real solution in (30).
Proof. P � 6k + 1 can be written in the form (6t + 1)(6r +
Substituting fn � h + n in (30), we obtain
1) and clearly; if A and 0 is the only solution, then
t2n − ao + 6h + 6n􏼁tn +(B − h − n) � 0. (32)
P � (6A + 1)(6 · 0 + 1) � 􏼒6 + 1􏼓1 � (P − 1 + 1)1,
P− 1

√��know that P has at least


√�� one prime
√�� factor
6 (23) However, we
P � P · 1. not exceeding P [36]. Ten, 6t + 1 ≤ P, or t ≤ P − 1/6.
Substituting for t in (33) to determine the maximum value
Conversely, let P � 6k + 1 be a prime. Clearly, P � (6k + for n � η, we obtain
□ √�� √�� √��
( P − 1)2 − 6 ao + 6h􏼁( P − 1) + 36(B − h)
1)(6 · 0 + 1); thus, A � k, 0 is the solution.
√��
P
n≤ ≈ . (33)
36 P 36
Corollary 2. If P � (6t + 1)(6r + 1) has at least one more
integral solution other than the trivial, then P is a composite. For maximum η, we choose the negative integer solution
of f in (32).
Suppose ho is the negative value of f; then, we obtain
√�� √�� √��
Proof. Suppose there exists a suitable value of r + t say r +
t � s ≠ A. Ten, u � tr ≠ 0. ( P − 1)2 − 6 ao + 6ho 􏼁( P − 1) + 36 B − ho 􏼁
√��
P
Let rt � u; then, t(s − t) � u: η≤ ≈ . (34)
36 P 36
st − t2 − u � 0, Ten, we can now obtain the exact integer solution for t
(24)
2
t − st + u � 0. recursively in simply ≤ η + ω iterations, where ω is the error
in n.
We use the quadratic formula given by During the iterations, we may reach a point when we
􏽰������ cannot obtain the integer solution for t, and as we reach tη ,
s ± s2 − 4u (25) the values of t tend to converge to some real number say τ,
t� .
2 and this requires us to do more iteration so that we can reach
������
at least t � 1. So, to reduce the iterations, we decide to simply
If √the integer numbers for t exist say
list down the remaining values of t if tη � τ > 1 right from 1
t � (s ± s2 − 4u /2) are integers, then
􏽰������ 􏽰������ to τ − 1 and do the trial divisions, and this is the error we

⎛ ⎝
⎛ ⎠
s + s2 − 4u ⎞ ⎠
⎞ ⎝
⎛ ⎝
⎛ ⎠ + 1⎞
s − s2 − 4u ⎞ ⎠.
assume to be ω.
m� 6 +1 6 (26) When we obtain exact integer solutions for t, then it
2 2
implies that, at least one of the t values gives a prime or a
Tus, it is a composite. □ number that divides P.
4 Journal of Mathematics

Case 4. P � (6t + 5)(6r + 5). We use the quadratic formula given by


􏽰��������

s2 − 100u
Theorem 3. Let t�
10
,

P � (6t + 5)(6r + 5). (35) 􏽰�������� 􏽰�������� (45)


m �⎛ ⎝s + s − 100u ⎞
⎝6⎛ ⎠ + 5⎞
⎠⎛ ⎝s − s − 100u ⎞
⎝6⎛ ⎠ + 5⎞
⎠.
2 2

Ten, there exists some integer A such that 10 10

A ≡ 5(r + t) (mod6). (36) Tus, a composite provided the values for t and r are
integers.
Clearly, if the values of t and r are not integers, then P is a
Proof. From prime. □
P � (6t + 5)(6r + 5) � 6[6tr + 5(r + t)] + 25, (37)
2.5. Factorizing the Composite of Case 4. Suppose P � (6t +
then
5)(6r + 5) is a composite. Ten, there exists some positive
P − 25 � 6[6tr + 5(r + t)]. (38) integer A such that A ≡ 5(t + r) (mod6)) as in (38). Let

Dividing through by 6, we obtain 5(t + r) � ao + 6f, (46)


P − 25 such that A − ao is divisible by 6, where f � 0, 1, 2, . . . , n
� 5(r + t) + 6rt. (39)
6 and ao is the smallest positive residue. Ten,
Now, let A � (P − 25/6) and u � rt imply that (41) rt � B − f, (47)
becomes
where B � A − ao /6
A � 5(r + t) + 6u. (40) From (48) and (49), we obtain
Hence, we obtain 5t2 − ao + 6f􏼁t + 5(B − f) � 0. (48)
A ≡ 5(r + t) (mod6). (41)
□ Since we are interested in the positive integer solution,
then
ao + 6f􏼁 − 100(B − f) ≥ 0.
2
Lemma 2. If 5(r + t) � A and A is divisible by 5, then P is (49)
divisible by 5.
By expanding, we obtain
Proof. Let 5(r + t) � A. We know that u � tr � 0. Ten, it 36f2 + 12ao + 100􏼁f − 100B + a2o ≥ 0. (50)
implies that r � A/5 − t:
Ten, let h be the least positive integer solution for f
t􏼒 − t􏼓 � 0.
A
(42) satisfying (52). Ten, fn � h + n, where n � 0, 1, . . . , η. Tis
5
implies that fmin � h for the real solution in (50).
Tus, t � 0 or t � (A/5). Substituting fn � h + n in (50), we obtain
5t2n − ao + 6h + 6n􏼁tn + 5(B − h − n) � 0.
When t � 0, r � (A/5) or when t � (A/5), r � 0, since
(51)
√�� √��
we know that 5 divides A, now, let ζ � A/5; substituting for
either t or r in equation (37), However, we know that 6t + 5 ≤ P; then, t ≤ ( P −
P � (6ζ + 5)(6 · 0 + 5) � (6ζ + 5)5. (43) 5/6). Substituting for t in (53) to determine the maximum
value for n � η, we obtain
Tus, P in (37) is divisible by 5, and therefore, P is not a √�� √�� √��
5( P − 5)2 − 6 ao + 6h􏼁( P − 5) + 180(B − h) 5 P
prime. □ n≤ √�� ≈ . (52)
36 P 36

Corollary 3. If P � (6t + 5)(6r + 5) has at least a nonzero For maximum η, we choose the negative integer solution
integer solution, then P is a composite. of f in (52).
Suppose ho is the negative value of f; then, we obtain
√�� √�� √��
Proof. Suppose there exists a suitable value of 5(r + t) say 5( P − 5)2 − 6 ao + 6ho 􏼁( P − 5) + 180 B − ho 􏼁 5 P
5(r + t) � s ≠ A. Ten, u � tr ≠ 0. η≤ √ �� ≈ . (53)
36 P 36
Let rt � u. Ten, t(s/5 − t) � u:
Ten, we can now obtain the exact integer solution for t
st − 5t2 − 5u � 0, recursively in simply ≤ η + ω iterations. When we obtain
(44)
5t2 − st + 5u � 0. exact integer solutions for t, then it implies that at least one
of the t values gives a prime or a number that divides P.
Journal of Mathematics 5

P � (6 · 0 + 1)(6A + 5) � 1 · 􏼒6 + 5􏼓,
3. Composites of the Form (6k + 5) and P− 5
Their Factorization 6 (65)
Theorem 4. Let P � (6t + 5)(6r + 1); then, there exist some P � 1 · P.
integer A such that
Implying if (56) has only a trivial solution, then 1 and P
A ≡ (5r + t) (mod6). (54) are the only divisors of P. □

Corollary 5. If there exists one more solution (nontrivial


Proof. From solution) of (56), then P is a multiple of primes greater than or
equal to 5.
P � (6t + 5)(6r + 1) � 6[6tr +(5r + t)] + 5, (55)

then Proof. Let s ≠ A and u ≠ 0 be the suitable integers such that


5r + t � s and tr � u; then,
P − 5 � 6[(5r + t) + 6tr]. (56)
s− t
r� ,
Dividing through by 6, we obtain 5

⇒􏼒 􏼓t − u � 0,
P− 5 s− t (66)
� (5r + t) + 6tr. (57)
6 5
Let A � P − 5/6 and k � tr; then,
t2 − st + 5u � 0.
A � (5r + t) + 6k, (58)
Applying quadratic formula, we obtain
implying 􏽰�������
s ± s2 − 20u (67)
A ≡ (5r + t) (mod6). (59) t� .
□ 2
√�������
√������
Te �
solution is either (s + s2 − 20u /2) or
Lemma 3. If 5r + t � A, then either r � (A/5), t � 0 or r � (s − s2 − 20u /2).
Substituting the solution in (56), we obtain
􏽰������� 􏽰�������
0, t � A is a trivial solution to (56).

P �⎛⎝6 + 5⎞⎠⎛
⎝6 ⎠ (68)
+ 1⎞
2
s + s − 20u s − s2 − 20u
Proof. Let 2 10
5r + t � A. (60)
or
Ten, 􏽰������� 􏽰�������
P �⎝
⎛6 s − + 5⎞⎠⎛
⎝6 ⎠. (69)
+ 1⎞
s2 − 20u s + s2 − 20u
rt � 0, (61) 2 10
√�������
√������
P is�a composite provided (s + s2 − 20u /2) and
implying that
Tus,
⇒t􏼒

􏼓 � 0.
A− t A− t (s − s2 − 20u /2) are integers.
r� (62)
5 5
Tus, t � 0 or t � A, when t � 0, r � (A/5) and when
t � A, r � 0. □ 3.1. Factorizing the Composite P � (6t + 5)(6r + 1).
Suppose P � (6t + 5)(6r + 1) is a composite. Ten, there
exists some positive integer A such that A ≡ 5r + t (mod6)
Corollary 4. When the trivial solution in Lemma 3 is the only
as in (56).
solution to (56), then P is either prime or divisible by 5.
Let

Proof. From (56), we need to show that P is either divisible 5r + t � ao + 6f, (70)
by 5 or has exactly two divisors that is 1 and P itself: such that A − ao is divisible by 6, where f � 0, 1, 2, . . . , n
P � (6r + 1)(6t + 5). (63) and ao is the smallest positive residue. Ten,

When t � 0, r � (A/5), then rt � B − f, (71)

P � 􏼒6 + 1􏼓(6 · 0 + 5) � 􏼒6 + 1􏼓5.
A P− 5 where B � (A − ao /6).
(64)
5 30 From (72) and (73), we obtain
Ten, P is divisible by 5, provided 5 divides A. t2 − ao + 6f􏼁t + 5(B − f) � 0. (72)
Or when t � A, r � 0, then
6 Journal of Mathematics

Since we are interested in the positive integer solution, (iv) We obtain the least positive integer fmin � h
then such that
t2 − (ao + 6f)t + (B − f) � 0 has a real
ao + 6f􏼁 − 20(B − f) ≥ 0.
2
(73) solution.
By expanding, we obtain Tis is obtained from (ao + 6f)2 − 4(B−
f) ≥ 0. √��
36f2 + 12ao + 20􏼁f − 20B + a2o ≥ 0. (74) (v) We obtain the integer n from n � η ≤ ( P /36),
where ho � − h.
Ten, let h be the least positive integer solution for f (vi) n � 0, 1, 2, . . . , η, 􏽱�����������������
fo � h, fn � h + n,� and
satisfying (76). Ten, fn � h + n, where n � 0, 1, . . . , η. Tis
implies that fmin � h for the real solution in (75). to � ((ao + 6h) ± (ao + 6h)2 − 4(B − h) /2).
Substituting fn � h + n in (75), we obtain If the integer solution does not exist at n � 0,
we do step (vii)
t2n − ao + 6h + 6n􏼁tn + 5(B − h − n) � 0. (75) (vii) We perform at most η iterations to obtain the
√�� integer solutions for t from
􏽱�������������������������
√��
However, we know from [7] that 6t + 5 ≤ P; then,
ao + 6h + 6n􏼁 ± ao + 6h + 6n􏼁 − 4(B − h − n)
2
t ≤ ( P − 5/6). Substituting for t in (77) to determine the tn � .
maximum value for n � η, we obtain 2
√�� √�� √�� (79)
( P − 5)2 − 6 ao + 6h􏼁( P − 5) + 180(B − h)


P
n≤ √ ≈ . (76)
36 P 36 Remark: If the values of t seem to converge at
some point on a real line, then it is better to list the
For maximum η, we choose the negative integer solution integer values of t from the point of convergence
of f in (76). (integer value of convergence) to as small as 1;
Suppose ho is the negative value of f; then, we obtain
√�� √�� √��
that is, if the integer value of convergence of t is τ,
( P − 5)2 − 6 ao + 6ho 􏼁( P − 5) + 180 B − ho 􏼁 then we list them such that t � τ − 1, . . . , 1 and
√��
P
η≤ ≈ . (77) do the trial divisions from P/6t + 1.
36 P 36
If there is no integer value of t such that
Ten, we can now obtain the exact integer solution for t (P/6t + 1) is an integer, then we try Case 4.
recursively in simply ≤ η iterations. When we obtain exact OR Case 4
integer solutions for t, then it implies that at least one of the t (i) We determine integer A from A � (P − 25/6).
values gives a prime or a number that divides P. (ii) We write down the congruence:
A ≡ 5(r + t) (mod6). (80)
4. General Outline of the Algorithm
(iii) We determine B and ao , where ao is the least
We outline the steps of factorizing primes based on the positive residue such that B � (A − ao /6) is a
proofs above. positive integer.
Given an integer P (iv) We obtain the least positive integer fmin � h
(1) Check if P satisfes P2 ≡ 1 (mod24). such that
(2) Does (1) hold? If so, do step (4), and if not, do step 5t2 − (ao + 6f)t + 5(B − f) � 0 has a real
(3). solution.
Tis is obtained from (ao + 6f)2 − 100(B −
√��
(3) Check if it is either divisible by 2 or by 3 and reduced f) ≥ 0.
it by dividing by 2 or 3 until the Quotient is no longer (v) We obtain the integer n from n � η ≤ (5 P /36),
divisible by 2 or 3. If the resulting Quotient is greater where ho � − h.
than 3, we can call it P and do step (4). (vi) n � 0, 1, 2, . . .􏽱 �������������������
, η, � to �
fo � h, fn � h + n, and
(4) Check if P is either of the form 6k + 1 or 6k + 5 by
((ao + 6h) ± (ao + 6h)2 − 100(B − h) /10).
subtracting 1 or 5 from P and check if the diference
If the integer solution does not exist at n � 0,
is divisible by 6.
we do step (vii).
(5) If P is of the form 6k + 1, then (vii) We perform at most η iterations to obtain the
􏽱���������������������������
Either Case 3 integer solutions for t from
(i) We determine integer A from A � (P − 1/6). ao + 6h + 6n􏼁 ± ao + 6h + 6n􏼁 − 100(B − h − n)
2

(ii) We write down the congruence: tn � .


10
A ≡ r + t (mod6). (78) (81)

(iii) We determine B and ao , where ao is the least Remark: If the values of t seem to converge at
positive residue such that B � A − ao /6 is a some point on a real line, then it is better to list
positive integer the integer values of t from the point of
Journal of Mathematics 7

B=BO,fO=h, a=ao, i=0,1,...,η

(ao+6h+6i) ± (ao+6h+6i)2−4(Bo−h−i) i=i+1


ti =
2

No
No
Is ti=t an integer? Is i=η?

Yes Yes
Yes
Compute P Is ti≤1?
6t+1
No No
Is P an integer?
6t+1
ti=1,...,τ−1,tη=τ
ERROR
Yes t=t+1
Compute P1= P
6t+1
Read P1 and P2 No
Yes No
Is P1 an integer? Is t=τ−1?
STOP
PRIME Yes Yes

TRY CASE II Done CASE II?


No

Figure 1: Algorithm for numbers of the form 6k + 1: Case 3.

convergence (integer value of convergence) to (vii) We perform at most η iterations to obtain the
as small as 1; that is, if the integer value of 􏽱�������������������������
integer solutions for t from �
convergence of t is τ, then we list them such that ao + 6h + 6n􏼁 ± ao + 6h + 6n􏼁 − 20(B − h − n)
2

t � τ − 1, . . . , 1 and do the trial divisions from tn �


2
.
P/6t + 5.
(83)
If there is no integer value of t such that
(P/6t + 5) is an integer, then P is a prime. Remark: if the values of t seem to converge at
(6) If P is of the form 6k + 5, then some point on a real line, then it is better to list the
integer values of t from the point of convergence
(i) We determine integer A from A � (P − 5/6). (integer value of convergence) to as small as 1;
(ii) We write down the congruence: that is, if the integer value of convergence of t is τ,
then we list them such that t � τ − 1, . . . , 1 and
A ≡ 5r + t (mod6). (82) do the trial divisions from P/6t + 5.
If there is no integer value of t such that
(iii) We determine B and ao , where ao is the least (P/6t + 5) is an integer, then P is a prime.
positive residue such that B � (A − ao /6) is a
positive integer.
(iv) We obtain the least positive integer fmin � h Example 1. We consider the factorizing of number
such that 1099551473989:
t2 − (ao + 6f)t + 5(B − f) � 0 has a real
A � 183258578994,
solution.
Tis is obtained from 183258578994 ≡ 5(t + r) (mod6),
(ao + 6f)2 − 4(B − f) ≥ 0. √�� B � 30543096499, ao � 0,
(v) We obtain the integer n from n � η ≤ ( P /36),
where ho � − h. 5t2 − 6ft + 5(30543096499 − f) � 0.
(vi) n � 0, 1, 2, . . . , η, 􏽱������������������
fo � h, fn � h + n, � and (84)
to � ((ao + 6h) ± (ao + 6h)2 − 20(B − h) )/2.
For real solution for t, we obtain 36f2 + 100f−
If the integer solution does not exist at n � 0,
3054309649900 ≥ 0:
we do step (vii).
8 Journal of Mathematics

B=BO,fO=h, a=ao, i=0,1,...,η

(ao+6h+6i) ± (ao+6h+6i)2−100(Bo−h−i) i=i+1


ti =
10

No
No
Is ti=t an integer? Is i=η?

Yes Yes
Yes
Compute P Is ti≤1?
6t+5
No No
Is P an integer?
6t+5
ti=1,...,τ−1,tη=τ
ERROR
Yes t=t+1
Compute P1= P
6t+1
Read P1 and P2 No
Yes No
Is P1 an integer? Is t=τ−1?
STOP
PRIME Yes
Yes
TRY CASE I Done CASE I?
No
Figure 2: Algorithm for numbers of the form 6k + 1: Case 4.

B=BO,fO=h, a=ao, i=0,1,...,η

(ao+6h+6i) ± (ao+6h+6i)2−20 (Bo−h−i) i=i+1


ti =
2

No
No
Is ti=t an integer? Is i=η?

Yes Yes
Yes
Compute P Is ti≤1?
6t+5
No No
Is P an integer?
6t+5
ti=1,...,τ−1,tη=τ
ERROR
Yes t=t+1
Compute P1*=
P P
Read P1 and P2 6t+5 ,P2* 6t+1 No
Yes No
Is P1* or P2* an integer? Is t=τ−1?
STOP
Yes

PRIME

Figure 3: Algorithm for numbers of the form 6k + 5.


Journal of Mathematics 9

fmin � h � 291275, ⇒ho � − 291275. (85) Acknowledgments


√�� √ �

� ��η ≤ (5( P − 5)2 − 6(ao + 6ho )( P − 5) +
Using nmax √ Te author thank Dr. Osman, Prof Mogtaba M, and Dr. M.
180(B − ho )/36 P ), then n � 􏽱 0,���������������������
1, 2, . . . , 582550. Sala for reading the work and helping prepare it and is
From to � ((ao + 6ho ) ± (ao + 6ho )2 − 100(B − ho ) / indebted to them.
10), we obtain
√��� References
6 × 291275 ± 100
to � . (86)
10 [1] J. Brillhart, D. H. Lehmer, and J. L. Selfridge, “New primality
criteria and factorizations of 2m ± 1,” Computing, vol. 29,
Ten, to � 174766 or to � 174764, and therefore, the pp. 620–647, 1975.
prime divisors of 1099551473989 are 1048601 and 1048589. [2] A. Granville, “It is easy to determine whether a given integer is
Te above procedures (general outline) can be sum• prime,” ulletin of the American Mathematical Society, vol. 42,
marized by the fowcharts in Figures 1–3, respectively. no. 1, pp. 3–38, 2004.
[3] S. K. Park and K. W. Miller, “Random number generators:
good ones are hard to fnd,” Communications of the ACM,
vol. 31, no. 10, pp. 1192–1201, 1988.
4.1. Algorithm for Numbers of the Form 6k + 1: Case 3. P, A �
[4] R. Jakimczuk, “Logarithm of the exponents in the prime
(P − 1/6), √B��� (A − ao /6), (ao + 6fo )2 − 4(B − fo ) ≥ 0, ho � factorization of the factorial,” International Mathematical
− fo , η ≤ ( P /36) Forum, vol. 12, pp. 643–649, 2017.
[5] P. Erdós, “On the normal number of prime factors of P•1 and
4.2. Algorithm for Numbers of the Form 6k + 1: Case 4. P, A � some related problems concerning euler’s ø•function,” Te
P − 25/6, B√���(A − ao /6)(ao + 6fo )2 − 100(B − fo ) ≥ 0, ho � Quarterly Journal of Mathematicsos, pp. 205–213, 1935.
[6] H. L. Montgomery and R. C. Vaughan, “Te large sieve,”
− fo ,η ≤ (5 P /36)
Mathematika, vol. 20, no. 2, pp. 119–134, 1973.
[7] K. H. Rosen, Elementary Number Teory and its Applications,
4.3. Algorithm for Numbers of the Form 6k + 5: Case 4. P, A � ADDISON•WESLEY PUBLISHING COMPANY, Boston,
�� (A − ao /6)(ao + 6fo ) − 20(B− fo ) ≥ 0, ho �
2 MA, USA, 1986.
P − 5/6, B√�
− fo ,η ≤ ( P /36) [8] M. O. Rabin, “Probabilistic algorithm for testing primality,”
Journal of Number Teory, vol. 12, no. 1, pp. 128–138, 1980.
[9] W. Edwin Clark, Elementary Number Teory, University of
5. Conclusion and Recommendations
South Florida, Florida, FL, USA, 2003.
Tis method is good especially when the diference (prime [10] J. Zalaket and J. Hajj•Boutros, “Prime factorization using
gap) between the prime divisors if relatively small. square root approximation,” Computers & Mathematics with
Applications, vol. 61, no. 9, pp. 2463–2467, 2011.
[11] J. V Uspensky and M. A. Heaslet, Elementary Number Teory,
Remark 1. Normally, when the prime divisors are close to McGraw•Hill Book Company Inc, New York, NY, USA, 1939.
each other, values of to are integer solutions. However, this [12] O. Narutaka and P. Sorin, “Some prime factorization results
may not guarantee for all such problems. for type II factors,” Inventiones Mathematicae, vol. 156,
Te algorithm is efective in prime factorization and pp. 223–234, 2004.
primality testing, especially when dealing with relatively [13] A. Overmars and S. Venkatraman, “A fast factorisation of
large numbers. However, there is need for a way of difer• semi•primes using sum of squares,” Mathematical and
entiating numbers of the form (6t + 1)(6r + 1) from Computational Applications, 2019.
numbers of the form (6t + 5)(6r + 5) because the end result [14] J. F. McKee, “Turning euler’s factoring method into a fac•
is of the form 6k + 1 which makes it difcult to choose which toring algorithm,” ulletin of the London Mathematical So•
algorithm is suitable for such numbers. Tis forces one to ciety, vol. 28, no. 4, pp. 351–355, 1996.
randomly select either Case 3 formula or Case 4 which [15] R. Solovay and V. Strassen, “A fast Monte•Carlo test for
primality,” SIAM Journal on Computing, vol. 6, no. 1,
makes it more tiresome in case the frst algorithm does not
pp. 84•85, 1977.
produce any result so you turn to another case before
[16] S. Y. Yan, “Primality testing of large numbers in maple,”
making any conclusion about the given problem. Computers & Mathematics with Applications, vol. 29, no. 12,
In addition, this algorithm requires a computer program pp. 1–8, 1995.
so that it carries a greater impact in the feld of cryptography [17] S. Y. Yan, “68 new large amicable pairs,” Computers &
and mathematics. Mathematics with Applications, vol. 28, no. 5, pp. 71–74, 1994.
[18] G. L. Miller, “Riemann’s hypothesis and tests for primality,”
Data Availability Journal of Computer and System Sciences, vol. 13, no. 3,
pp. 300–317, 1976.
Te fgures data used to support the fndings of this study are [19] R. J. Baillie and S. S. Wagstaf, “Lucas pseudoprimes,”
included within the article. Mathematics of Computation, vol. 35, no. 152, pp. 1391–1417,
1980.
Conflicts of Interest [20] A. Dunn and A. Zaharescu, “Sums of kloosterman sums over
primes in an arithmetic progression,” Te Quarterly Journal of
Te authors declare that they have no conficts of interest. Mathematics, vol. 70, no. 1, pp. 319–342, 2019.
10 Journal of Mathematics

[21] H.•M. Sun, M.•E. Wu, W.•C. Ting, and M. Hinek, “Dual RSA
and its security analysis,” IEEE Transactions on Information
Teory, vol. 53, no. 8, pp. 2922–2933, 2007.
[22] G. P. Michon, “Factoring into primes,” 2020, http://www.
numericana.com/answer/factoring.htm.
[23] R. L. Rivest, A. Shamir, and L. Adleman, “A method for
obtaining digital signatures and public•key cryptosystems,”
Communications of the ACM, vol. 21, no. 2, pp. 120–126, 1978.
[24] M. Agrawal, N. Kayal, and N. Saxena, “PRIMES is in P,”
Annals of Mathematics, vol. 160, no. 2, pp. 781–793, 2004.
[25] C. Pomerance, “On the distribution of pseudoprimes,”
Mathematics of Computation, vol. 37, no. 156, pp. 587–593,
1981.
[26] R. Hans, Prime Number And Computer Methods for Factor•
ization irkhauser, p. pg3, Birkhäuser, Boston, MA, USA,
2012.
[27] L. M. Adleman, C. Pomerance, and R. S. Rumely, “On dis•
tinguishing prime numbers from composite numbers,” An•
nals of Mathematics, 1983.
[28] R. Schoof, “Four primality testing algorithms,” Algorithmic
Number Teory, vol. 44, 2008.
[29] H. W. Lenstra, “Factoring integers with elliptic curves,”
Annals of Mathematics, vol. 126, no. 3, pp. 649–673, 1987.
[30] J. M. Pollard, “Teorems on factorization and primality
testing,” Mathematical Proceedings of the Cambridge Philo•
sophical Society, vol. 76, no. 3, pp. 521–528, 1974.
[31] C. Harvey, Advanced Number Teory, p. pg10, Dover Pub•
lications. Inc, New York, NY, USA, 1980.
[32] G. Tenenbaum and M. Mendes France, Te Prime Numbers
and Teir Distribution, American Mathematical Society,
Washington, WA, USA, 1997.
[33] R. D. Carmichael, “On composite numbers p which satisfy the
Fermat congruence.ap•1�1modp,” Te American Mathemat•
ical Monthly, vol. 19, pp. 22–27, 1912.
[34] M. L. Weber, “It’s a wonderful world • and universe • out
there,” 2020, https://www.snexplores.org/article/explainer•
what•is•an•algorithm.
[35] J. W. Porras Ferreira and C. G. Willian De Jesus, “An Analysis
of the Congruence 1mod24 as a Generator of prime numbers
Greater or Equal to 5,” Current Journal of Applied Science and
Technology, vol. 14, pp. 2231–0843, 2016, http://
sciencedomain.org/review•history/13307.
[36] Z. Joseph and B. Joseph Hajj, “Prime factorization using
square root approximation,” Computers & Mathematics with
Applications, vol. 61, 2011, http://www.sciencedirect.com/
science/article/pii/S0898122111001131.

You might also like