A New Algorithmic Approach to Integer Divisibility and Factorization

Abstract

This article proposes an algorithmic method for testing divisibility, grounded in the relationships between the multiplication tables of consecutive divisors. The algorithm generates, through an iterative process, a sequence of quotients and differences that makes detecting divisibility easier. This approach also offers a representation of odd integers as alternating sums of multiples, paving the way for the formulation of the Kadouno—Serre conjecture, which concerns the convergence of alternating series. The algorithm is then extended to pairs of non-consecutive divisors, along with a mathematical study of its convergence. Finally, a hybrid version—combining this method with an optimized initialization of Fermat’s factorization—is proposed to improve efficiency on balanced semiprimes. Potential applications are outlined, notably in pedagogy and number theory.

Share and Cite:

Kadouno, G.J. (2025) A New Algorithmic Approach to Integer Divisibility and Factorization. Advances in Pure Mathematics, 15, 472-482. doi: 10.4236/apm.2025.157022.

1. Introduction

Arithmetic—the foundational science of mathematics—has enthralled scholars since antiquity thanks to the richness of its internal structures. Among the many areas explored, the questions of divisibility and factorization of integers remain central to number theory.

Driven by a personal passion for whole numbers, I have developed a technique based on what I call alternating profiles: a sequence of quotients obtained by adjusting an odd integer N until it becomes divisible by a given divisor b. Born from empirical experimentation, this idea gradually led me to this algorithm—an original approach for testing divisibility, optimizing certain arithmetic operations, and formulating a general conjecture about odd integers.

This article has three goals:

1) To present the method rigorously, supported by clear mathematical proofs.

2) To explore its applications, especially in pedagogy and number theory.

3) To unify classical divisibility criteria under a common algorithmic framework—particularly for integers n3 —thereby moving beyond the multiplicity of traditional rules.

Rooted in clarity, curiosity, and experimentation, this research extends the method to non-consecutive divisors and proposes a hybrid variant inspired by Fermat’s theorem. Through numerical examples and theoretical formalization, we show how this approach can deepen our understanding of divisibility in a modern context [1].

2. Methodology of the Algorithm

Unified Divisibility Approach Based on Multiplication Tables

1) Conceptual Foundations

The algorithm rests on a fundamental relation between two consecutive integers a and b=a+1 and their multiplication tables:

T( a )={ an|n },T( b )={ bn|n }.

Because b=a+1 ,

bn=an+n T( b )[ n ]=T( a )[ n ]+n (1)

Hence, for every index n , the difference between T( b )[ n ] and T( a )[ n ] is exactly n . This regularity allows an iterative divisibility-testing algorithm.

2) General Definition of the Algorithm

Goal. Test whether an integer F is divisible by an integer b using its predecessor a=b1 .

Step 1: Initialisation

F 0 =F,b( candidate divisor ),a=b1( predecessor ).

Step 2: Iterations — for each iteration i :

q i = F i a

K i =b  q i

F i+1 = K i F i (2)

Step 3: Stopping criterion

  • If F i+1 =0 , then Fisdivisiblebyb .

  • If F i+1 <0 , then Fisnotdivisiblebyb .

3) Worked Examples for Various Divisors

Divisor b=5 ( a=4 ) Example 1: F=45 (two digits)

q 0 = 45/4 =11, K 0 =511=55, F 1 =5545=10

q 1 = 10/4 =2, K 1 =10, F 2 =1010=0

45isdivisibleby5

Example 2: F=47 (two digits)

q 0 = 47/4 =11, K 0 =55, F 1 =5547=8

q 1 = 8/4 =2, K 1 =10, F 2 =108=2

q 2 = 2/4 =0, K 2 =0, F 3 =02=2

47isnotdivisibleby5

Divisor b=7 ( a=6 ) Example 3: F=126 (three digits)

q 0 = 126/6 =21, K 0 =721=147, F 1 =147126=21

q 1 = 21/6 =3, K 1 =21, F 2 =2121=0

126isdivisibleby7

Divisor b=13 ( a=12 ) Example 4: F=1235 (four digits)

q 0 = 1235/ 12 =102, K 0 =13×102=1326, F 1 =13261235=91

q 1 = 91/ 12 =7, K 1 =91, F 2 =9191=0

1235isdivisibleby13

Divisor b=17 ( a=16 ) Example 5: F=15300 (five digits)

q 0 = 15300/ 16 =956, K 0 =17×956=16252, F 1 =1625215300=952

q 1 = 952/ 16 =59, K 1 =17×59=1003, F 2 =1003952=51

q 2 = 51/ 16 =3, K 2 =17×3=51, F 3 =5151=0

15300isdivisibleby17

4) Summary

Divisorb a=b1 ExampleF Divisible? 5 4 45 Yes 7 6 126 Yes 13 12 1235 Yes 17 16 15,300 Yes 5 4 47 No

Pedagogical Advantage: The algorithm uses only elementary operations (integer division, multiplication, subtraction), making it especially suitable for teaching divisibility as early as secondary school. It promotes an active understanding of multiplication tables and the gaps between successive multiples by re-employing familiar notions (quotients, remainders, differences) [2] [3].

3. Convergence Analysis of the Iterative Algorithm

General Setting

The divisibility test for F 0 by b is defined by

q i = F i a , F i+1 =( a+δ ) q i F i (3)

with δ=ba . Convergence to F n =0 depends critically on a , δ , and F 0 .

Critical Cases Analysis (with F 0 =255 , b=5 )

Case 1: a=4,δ=1 . Iterations:

F 1 =563255=60, F 2 =51560=15, F 3 =5315=0.

Iterations: 3. Behaviour: rapid decrease 25560150 . Explanation: small δ=1 gives efficient convergence.

Case 2: a=3,δ=2 — slow convergence (9 iterations).

F 1 =585255=170, F 2 =556170=110, F 3 =536110=70, F 4 =52370=45, F 5 =51545=30, F 6 =51030=20, F 7 =5620=10, F 8 =5310=5, F 9 =515=0.

Summary: non-monotone convergence 2551701100 .

Case 3: a=2,δ=3 . First iteration:

F 1 =5127255=380> F 0 ( growth ).

Behaviour: temporary divergence; more than 15 iterations needed to converge. Explanation: large δ=3 amplifies residuals.

Proof for 1 ¯ .

q i = F i F i+1 =b F i F i =( b1 ) F i (4)

If b>2 , then | F i+1 |>| F i | , leading to exponential growth.

4. Mathematical Analysis

Let F i be the residue at step i . We have

F i+1 =δ q i r i ,where F i =a q i + r i ,0 r i <a.

Order of magnitude.

F i+1 δ F i a r i (5)

Critical cases.

  • If δ<a : exponential decrease ( δ/a <1 ).

  • If δ>a : possible growth ( δ/a >1 ).

Optimisation

To speed up convergence:

1) Choose a close to b (i.e. δ small).

2) Avoid ab (e.g. a< b ).

3) In practice, prefer δ2 .

Pedagogical Applications

In the game “Divisor Hunt”

  • Recommended: δ=1 or δ=2 .

  • Avoid: δ3 or a=1 (risk of frustration or explosion).

Conclusion.

  • Convergence is guaranteed if b| F 0 , but speed depends on a and δ .

  • Optimal speed at δ2 (e.g. b=a+1 ).

  • Instabilities for δ3 or a=1 .

5. Generalised Divisibility Theorem

Statement. Let

  • a,δ + ,b=a+δ .

  • F 0 .

  • Sequence { F i } i1 defined by

q i = | F i1 | a sgn( F i1 ), F i =b q i F i1 .

Then, for every n1 ,

F 0 = ( 1 ) n+1 F n +b k=1 n ( 1 ) k+1 q k (6)

In particular, if F n =0 , then

F 0 =b k=1 n ( 1 ) k+1 q k (7)

Hence F 0 is divisible by b .

Proof

1) Initialization. Define recursively:

F 0 given, F i =b q i F i1 F i1 =b q i F i

2) Iterative unfolding.

F 0 =b q 1 F 1

F 1 =b q 2 F 2 F 0 =b( q 1 q 2 )+ F 2

F 2 =b q 3 F 3 F 0 =b( q 1 q 2 + q 3 ) F 3

F 3 =b q 4 F 4 F 0 =b( q 1 q 2 + q 3 q 4 )+ F 4

Signs alternate at each step.

3) Induction/generalisation. Therefore,

F 0 = ( 1 ) n+1 F n +b k=1 n ( 1 ) k+1 q k

If F n =0 , we recover Equation (8).

Important remark

Explanation of ( sgn( F i1 ) ) in the Formula (Page 8, Section 7)

In the formula of the Generalised Divisibility Theorem

q i = | F i1 | a sgn( F i1 ),

the term sgn( F i1 ) denotes the sign function of F i1 , defined by

sgn( F i1 )={ +1, if F i1 >0, 1, if F i1 <0, 0, if F i1 =0.

Role in the Algorithm

1) Handling Negative Values

  • The algorithm may produce negative values for F i (e.g. F 3 =2 when b=5 and F=47 , Page 3).

  • The function sgn keeps the sign of F i1 after division by a , so that the quotient q i correctly reflects whether the next adjustment is additive or subtractive.

2) Ensuring Convergence

  • By combining sgn with the absolute value | F i1 | , the formula drives the sequence { F i } toward 0 whenever b| F 0 , even when intermediate remainders become negative.

  • NB: Equation (7) holds for any ( a,b ) with b=a+δ .

  • NB: the special case δ=1b=a+1 corresponds to consecutive tables.

Illustrative Example

Take a=4 , b=5 , F 0 =35 .

q 1 = 35/4 =8, F 1 =5×835=5

q 2 = 5/4 =1, F 2 =5×15=0

35=b( q 1 q 2 )=5( 81 )=5×7

6. Corollary (Kadouno-Serre Conjecture)

Statement. Let N be odd. For each divisor b + of N , there is a finite sequence { q k } k=1 n constructed by the algorithm with

a=b1,δ=1, q i = F i1 a , F i =b q i F i1 , F 0 =N,

such that

N=b k=1 n ( 1 ) k+1 q k

Iterative proof. The theorem’s algorithm gives

F i =b q i F i1

and unfolding yields

F 0 = ( 1 ) n+1 F n +b k=1 n ( 1 ) k+1 q k .

Since b|N and the algorithm ends with F n =0 , the desired alternating representation of N follows.

Numerical Examples

Example 1: N=35,b=5 .

q 1 =8, F 1 =5, q 2 =1, F 2 =0

35=5( 81 )=5×7

Example 2: N=105,b=7 .

q 1 =17, F 1 =14, q 2 =2, F 2 =0

105=7( 172 )=7×15

Example 3: N=255,b=5 .

q 1 =63, F 1 =60, q 2 =15, F 2 =15, q 3 =3, F 3 =0

255=5( 6315+3 )=5×51

Pedagogical and Theoretical Remarks

  • The alternating representation is canonical for each pair ( N,b ) , giving an “Alternating signature” of N .

  • It is constructive, relying solely on integer divisions by a=b1 .

  • It applies to any divisor of any odd integer.

7. Conclusion

The Kadouno—Serre Conjecture, proved here as a corollary, asserts that every odd integer N can be expressed as an alternating sum of multiples of each of its divisors through a universal algorithm based on consecutive multiplication tables. This structure reveals a hidden form of divisibility with both algorithmic and pedagogical implications [4].

8. Theorem (Fermat)

Let

N( odd,non-square ),N=pq,p<qoddprimes.

Then there exist integers

r,ksuchthatN= r 2 k 2 =( rk )( r+k ).

Thus, once N is written as a difference of two squares, its factors emerge immediately.

1) Fundamental Identity N= r 2 k 2

Proof. Start from the algebraic identity

r 2 k 2 =( rk )( r+k ).

With N=p q ( p<q , both odd), set

r:= p+q 2 ,k:= qp 2 .

Because p and q are odd, p+q 2 and qp 2 are integers. Hence

r+k=q,rk=p,

and therefore

( rk )( r+k )=p q=N,

proving

N= r 2 k 2 .

2) Algorithmic Application: FermatHybrid

Goal. Recover p and q from N without prior knowledge by testing integers r that satisfy

r 2 N= k 2 .

3) Fermat-Hybrid Procedure

a) Initialisation. Start at

r 0 := N .

Since r 2 =N+ k 2 >N , any valid r must satisfy r> N ; the smallest such integer is N .

b) Iteration. For r i = r 0 , r 0 +1, r 0 +2, compute

d i := r i 2 N.

If d i is a perfect square, set

k= d i ,p= r i k,q= r i +k.

Consequently

p q=( r i k )( r i +k )= r i 2 k 2 =N,

so N is factored.

4) Complexity Analysis

Balanced case pq . Here

r= p+q 2 N ,

so

r 2 N= k 2

is very small—usually a perfect square within one or two trials.

General case pq . Then

r= p+q 2 N ,k= qp 2 0, r 2 N= k 2 0.

Many iterations may be required; hybridising with trial division or probabilistic tests mitigates this delay.

5) Detailed Examples

Example 1: N=221 .

221 14.87 r 0 =15,d= 15 2 221=4= 2 2 .

Hence

p=152=13,q=15+2=17,13×17=221.

Example 2: N=2021 .

2021 44.94 r 0 =45,d= 45 2 2021=4= 2 2 .

Thus

p=452=43,q=45+2=47,43×47=2021.

6) Geometric View

Writing

N= r 2 k 2

models N as the area difference between a large square of side r and a small square of side k . Removing the small square leaves a rectangle of dimensions

rk and r+k ,

i.e. the factors p=rk and q=r+kofN [5].

Figure 1. Geometric representation of the factorization N= r 2 k 2 .

Visual model of the Fermat-Hybrid method. A large square with side length r (area r 2 ) contains a smaller square with side length k (area k 2 ). The difference in areas, N= r 2 k 2 , corresponds to the shaded rectangle with dimensions ( rk )×( r+k ) , revealing the factors p=rk and q=r+k of N .

As illustrated in Figure 1, the identity N= r 2 k 2 provides an effective geometric visualization of the factorization into p×q ...

7) Advantages of the FermatHybrid Method

  • Optimal start. Starting at Square N, minimizes the number of tests, unlike the worst-case scenario where Fermat’s method may require testing up to [N + 1]/2.

  • Efficiency. For semiprimes with small | pq | , factoring is nearly immediate.

  • Hybrid flexibility. The approach can be combined with other methods when divergence occurs.

Note. The identity

N= r 2 k 2

allows instant factorisation once a suitable r is found. Beginning at

r 0 = N

guarantees best-case performance, especially for pq .

9. Overall Conclusions

This study has presented an algorithmic framework for testing divisibility based on consecutive multiplication tables. Blending formal reasoning with numerical intuition, it offers an alternative to classical techniques.

The Kadouno—Serre Conjecture, established herein, shows that every odd number can be written as an alternating sum of multiples of any of its divisors. This structural property sheds new light on integer representations and may inspire further work in number theory.

Extending the algorithm to non-consecutive divisors and hybridising it with factorisation methods such as Fermat’s broadens its applicability. Empirical tests confirm rapid convergence when divisors are close, while limitations emerge as their gap widens.

Finally, a practical implementation—the Le-Kadouno Calculator app on the Play Store—makes the method readily explorable for both educational and computational purposes. This research opens avenues for future work on algorithmic optimisation and theoretical applications of the conjecture [6].

Conflicts of Interest

The author declares no conflicts of interest regarding the publication of this paper.

References

[1] Schoenfeld, A.H. (2022, November) How We Think: A Theory of Goal-Oriented Decision Making in Mathematics Education. Routledge.
https://www.routledge.com/How-We-Think-A-Theory-of-Goal-Oriented-Decision-Making-and-its-Educational-Applications/Schoenfeld/p/book/9780415878654
[2] Zazkis, R. and Liljedahl, P. (2020, July) Teaching Mathematics through Algorithmic Problem Solving. Journal of Mathematics Teacher Education, 23, 345-367.
[3] Ball, D.L., Thames, M.H. and Sleep, L. (2021, March) Reimagining Arithmetic: Pedagogical Tools for Divisibility and Primes. Educational Studies in Mathematics, 107, 123-145.
[4] Confrey, J. and Maloney, A. (2019, May) Designing Learning Trajectories for Divisibility Concepts in Middle School. Digital Experiences in Mathematics Education, 5, 1-25.
[5] Kuldeep, G. and Jacobsen, R.H. (2024) Revisiting Fermat’s Factorization Method. Cryptology ePrint Archive, Paper 2024/1722.
https://eprint.iacr.org/2024/1722
[6] Sinclair, N. and Heyd-Metzuyanim, E. (2023, February) Learning Mathematics through Algorithmic Thinking: A Case of Divisibility Rules. International Journal of STEM Education, 10, 1-18.

Copyright © 2025 by authors and Scientific Research Publishing Inc.

Creative Commons License

This work and the related PDF file are licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.