Ramanujan-Inspired Prime Sums through Prime Gaps

Abstract

In this study, we develop a finite framework for studying sums of prime numbers through consecutive prime gaps. This work is motivated by Ramanujan’s influence on arithmetic decompositions, partition methods, and summation ideas, but the argument itself remains within ordinary finite number theory. The main result is an exact finite rearrangement of the partial prime sum: the sum of the first n primes is written as the contribution of the initial prime together with a weighted accumulation of consecutive prime gaps. Each gap receives a weight equal to the number of later primes affected by that gap. The same identity is also expressed geometrically, where the weighted gap contribution appears as the slope relation in a right triangle. Exact examples verify the formula for small prime sums, and the asymptotic discussion places the identity beside the classical leading scale predicted by the prime number theorem. This paper also separates finite identities from regularized infinite summations, while divergent infinite prime sums require a separate summation theory and cannot be treated as ordinary convergent series.

Share and Cite:

Danesh, P. and Bianchetti, R. (2026) Ramanujan-Inspired Prime Sums through Prime Gaps. Journal of Applied Mathematics and Physics, 14, 2509-2521. doi: 10.4236/jamp.2026.147124.

1. Introduction

Prime numbers form one of the central structures of arithmetic [1]. Their distribution has shaped number theory from Euler’s formula to the prime number theorem and modern work on prime gaps [2]. The usual objects in this area are the prime-counting function, Chebyshev functions, divisor functions, and asymptotic estimates for the sequence of primes [3]. A simpler finite object also carries useful information: the sum of the first n primes. This sum records not only the size of the primes themselves, but also the way consecutive prime gaps accumulate through the sequence. To make this accumulation precise, we first write the prime sum in a fixed notation and then express each prime through the gaps that precede it.

Let p n denote the n -th prime, and define the partial prime sum by

P n = k=1 n p k . (1)

The central observation of this paper is that P n has an exact decomposition in terms of consecutive prime gaps. If

g i = p i+1 p i , (2)

then

P n =2n+ i=1 n1 ( ni ) g i . (3)

The term 2n is the baseline contribution from the initial prime 2. The remaining term records the accumulated effect of the prime gaps. A gap g i is not counted once. It is counted with weight ni , because it affects every later prime from p i+1 through p n . In this way, Formula (3) gives a finite history of how the prime sequence is built from its successive differences.

The motivation of this study is partly Ramanujan-inspired since Ramanujan’s work on highly composite numbers showed how arithmetic objects can be understood through structured decompositions, extremal behavior, and cumulative effects in multiplicative number theory [4]. In 1918, Hardy and Ramanujan’s work on partitions remains another model for reorganizing arithmetic information into forms where cumulative structure becomes visible [5]. Later, Nicolas and Robin studied Ramanujan’s work in detail and clarified its connection with divisor functions, prime factors, and extremal arithmetic behavior [6]. The finite sum of the first n primes belongs naturally to the classical theory of prime distribution. The prime number theorem gives the leading scale of prime growth, and Goldstein’s historical account explains how this subject developed from numerical evidence into rigorous asymptotic theory [7]. More recent works study P n directly. For example, Axler obtained asymptotic formulas and explicit estimates for the sum of the first n primes [8]. Sinha also derived an asymptotic expansion for the same quantity and connected it with inequalities of Mandl and Robin type [9]. Although all these works address the analytic growth of P n , the present paper serves a different purpose. It gives an exact finite decomposition that makes the contribution of each individual prime gap explicit. Prime gaps provide the natural language for this decomposition. The differences p i+1 p i contain fine information about the local behavior of the prime sequence. Soundararajan’s survey on small gaps between primes shows how deep this subject becomes when one studies the distribution and size of these gaps [10]. Here the gaps are used in a more elementary but exact way. They are not estimated statistically. They are placed into a finite weighted identity for P n . This gives a direct bridge between local increments of the prime sequence and the global partial sum.

The same identity also has a geometric form. For fixed n , define

h i =ni. (4)

If an angle α i is chosen so that

tan α i = g i h i , (5)

then

g i = h i tan α i , (6)

and the prime-sum identity becomes

P n =2n+ i=1 n1 ( ni ) 2 tan α i . (7)

This trigonometric expression is an encoding of the same finite identity, not an independent method for predicting primes. The angle α i is defined from the gap g i . The geometric form therefore preserves the arithmetic content of Formula (3) rather than adding new information about the distribution of primes.

A separate issue concerns divergent infinite sums. Ramanujan’s name is often connected with non-standard summation ideas, and Ramanujan sums continue to appear in modern mathematical and signal-processing settings [11]. Such methods have value when they are used inside a precise regularization framework. They are not ordinary finite summation. For this reason, the present paper keeps the finite identity separate from any regularized infinite interpretation. The series of all primes diverges in the ordinary sense, and any finite value assigned to it would require separate definitions and separate proofs. In fact, the present paper follows a related mathematical attitude: a finite arithmetic quantity is rewritten so that its internal structure becomes transparent.

As the conclusion, this paper accurately proves Formula (3), verifies it by finite examples, gives its geometric encoding, and compares its scale with the known asymptotic behavior of prime sums.

2. Prime Gaps and Partial Prime Sums

To prove the finite rearrangement precisely, we first fix the notation for the prime sequence, its consecutive gaps, and the partial sums built from them.

Let

p 1 =2, p 2 =3, p 3 =5, p 4 =7, (8)

be the increasing sequence of prime numbers. For each integer i1 , define the i -th prime gap by

g i = p i+1 p i . (9)

Thus, the first few gaps are

g 1 =1, g 2 =2, g 3 =2, g 4 =4, g 5 =2. (10)

These gaps recover the prime sequence by telescoping. For every k1 ,

p k = p 1 + i=1 k1 ( p i+1 p i ). (11)

Since p 1 =2 , this becomes

p k =2+ i=1 k1 g i . (12)

Equation (12) is the basic finite relation used throughout the paper. It says that each prime is obtained from the first prime by adding all previous gaps.

We define the partial sum of the first n primes by

P n = k=1 n p k . (13)

The notation P n is used deliberately. In standard number theory, π( x ) denotes the number of primes not exceeding x . Using π( n ) for a sum of primes would conflict with this standard notation. In this case, the symbol P n keeps the object clear.

The goal is to rewrite P n in terms of the gaps g i . A gap that occurs early in the prime sequence appears in many later primes. These repeated appearances are the source of the weights in the main formula.

For example, take n=5 . The first five primes are

2,3,5,7,11. (14)

They can be written through gaps as

2 =2, 3 =2+ g 1 , 5 =2+ g 1 + g 2 , 7 =2+ g 1 + g 2 + g 3 , 11 =2+ g 1 + g 2 + g 3 + g 4 . (15)

Adding the five lines in (15), the baseline 2 appears five times. The first gap g 1 appears four times, g 2 appears three times, g 3 appears twice, and g 4 appears once. Hence

P 5 =25+4 g 1 +3 g 2 +2 g 3 + g 4 . (16)

This example shows the general pattern. In the sum P n , the gap g i appears exactly ni times. The main theorem in the next section formalizes this observation.

3. Decomposition of Prime Sums

We now prove the finite identity stated in the Introduction. The proof will show that the sum of the first n primes is determined by the first prime and by a weighted record of the gaps that follow it.

Theorem 3.1. Prime-gap decomposition

For every integer n1 ,

P n =2n+ i=1 n1 ( ni ) g i . (17)

Equivalently,

k=1 n p k =2n+ i=1 n1 ( ni )( p i+1 p i ). (18)

Proof

From (12), each prime p k can be written as

p k =2+ i=1 k1 g i . (19)

Summing (19) over k=1,,n , we obtain

P n = k=1 n ( 2+ i=1 k1 g i ). (20)

Separating the constant term gives

P n =2n+ k=1 n i=1 k1 g i . (21)

We now count how often each fixed gap occurs. The gap g i appears in the inner sum exactly when

ki+1. (22)

For a fixed i with 1in1 , this means

k=i+1,i+2,,n. (23)

There are ni such values of k . Therefore,

k=1 n i=1 k1 g i = i=1 n1 ( ni ) g i . (24)

Substituting (24) into (21) gives

P n =2n+ i=1 n1 ( ni ) g i . (25)

This proves the theorem.

Corollary 3.2. Accumulated gap contribution

For every integer n1 ,

P n 2n= i=1 n1 ( ni ) g i . (26)

Proof

Subtract 2n from both sides of (17).

Formula (26) isolates the part of the prime sum produced by the gaps. The term 2n is only the contribution of the initial prime repeated n times. Everything beyond that baseline is carried by the weighted gap sum.

The weight ni has a direct meaning. The gap g i shifts every later prime from p i+1 through p n . It therefore contributes once to each of those later primes. That is why it appears ni times in P n . Early gaps have larger weights. Later gaps have smaller weights.

Remark 3.3. Relation with finite differences.

The identity in Theorem 3.1 can also be read as a finite-difference form of summation by parts. The gaps g i = p i+1 p i are the forward differences of the prime sequence. Writing each prime as the initial value p 1 =2 plus the accumulated forward differences, and then summing over k , gives the weights ni . Thus Formula (17) is not a new summation method. It is the standard finite reconstruction of a sequence from its first term and its forward differences, followed by a finite change in summation order. Its usefulness here is that it makes the contribution of each individual prime gap visible inside the partial prime sum.

The notation in the decomposition is summarized in Table 1. The table is included to make clear that the index k refers to primes, while the index i refers to gaps. This distinction prevents a common confusion in formulas involving prime sums.

Table 1. Notation and arithmetic role in the prime-gap decomposition.

Symbol

Definition

Role

p k

k-th prime

prime being summed

g i

p i+1 p i

gap between consecutive primes

P n

k=1 n p k

sum of the first n primes

ni

gap multiplicity

number of later primes affected by g i

2n

n copies of p 1 =2

baseline contribution

4. Numerical Verification and Finite Examples

The decomposition is finite, so it must agree exactly with ordinary prime sums. The examples below check the identity in small cases and show how the weights appear in practice.

For n=5 , the first five primes are

2,3,5,7,11. (27)

The corresponding gaps are

g 1 =1, g 2 =2, g 3 =2, g 4 =4. (28)

Using Theorem 3.1, we get

P 5 =25+4 g 1 +3 g 2 +2 g 3 + g 4 . (29)

Substituting the gaps gives

P 5 =10+4( 1 )+3( 2 )+2( 2 )+1( 4 )=28. (30)

The ordinary sum gives the same value:

2+3+5+7+11=28. (31)

For n=6 , the first six primes are

2,3,5,7,11,13. (32)

Their gaps are

g 1 =1, g 2 =2, g 3 =2, g 4 =4, g 5 =2. (33)

The decomposition gives

P 6 =26+5 g 1 +4 g 2 +3 g 3 +2 g 4 + g 5 . (34)

Thus

P 6 =12+5( 1 )+4( 2 )+3( 2 )+2( 4 )+1( 2 )=41. (35)

Again, this matches the direct computation

2+3+5+7+11+13=41. (36)

The same verification for several small values of n is given at Table 2. Each row compares the ordinary sum with the weighted-gap expression. The agreement is exact because both columns represent the same finite identity.

Table 2. Exact verification of the prime-gap decomposition for small prime sums.

n

First n primes

Weighted-gap expression

P n

5

2,3,5,7,11

10+4( 1 )+3( 2 )+2( 2 )+1( 4 )

28

6

2,3,5,7,11,13

12+5( 1 )+4( 2 )+3( 2 )+2( 4 )+1( 2 )

41

7

2,3,5,7,11,13,17

14+6( 1 )+5( 2 )+4( 2 )+3( 4 )+2( 2 )+1( 4 )

58

8

2,3,5,7,11,13,17,19

16+7( 1 )+6( 2 )+5( 2 )+4( 4 )+3( 2 )+2( 4 )+1( 2 )

77

The triangular pattern of the weights is visible in the table. For P 8 , the first gap has weight 7, the second has weight 6, and the weights decrease by one until the final gap has weight 1. The arithmetic variation comes from the gaps themselves, while the weight pattern comes only from the finite summation structure.

The same structure is also visible in Figure 1. For n=12 , the figure displays

Figure 1. Weighted contribution of prime gaps to P n .

both the decreasing multiplicity ni and the actual weighted contribution ( ni ) g i .

This plot separates two effects: the deterministic decline of the weights and the arithmetic variation of the gaps. The i -th gap g i contributes with weight ni , so early gaps have the largest structural influence on the finite prime sum.

5. Geometric Encoding of Weighted Gaps

The prime-gap decomposition also has a useful geometric form. This section does not introduce a new prime-generating rule but it gives an exact visual encoding of the same finite identity proved in Theorem 3.1. It records the factor ( ni ) g i as a slope-height product and makes the weighted nature of the gap contribution visible in a single diagram.

Fix an integer n2 . For each gap g i , define

h i =ni. (37)

The number h i is the multiplicity of the gap g i in the sum P n . Define an angle α i by

tan α i = g i h i . (38)

Equivalently,

g i = h i tan α i . (39)

Substituting (39) into the gap decomposition gives

P n =2n+ i=1 n1 h i g i . (40)

Since g i = h i tan α i , we obtain

P n =2n+ i=1 n1 h i 2 tan α i . (41)

Using h i =ni , this becomes

P n =2n+ i=1 n1 ( ni ) 2 tan α i . (42)

Proposition 5.1. Geometric form

For every integer n2 ,

P n =2n+ i=1 n1 ( ni ) 2 tan α i , (43)

where

tan α i = p i+1 p i ni . (44)

Proof

By definition,

p i+1 p i = g i =( ni )tan α i . (45)

Therefore,

( ni ) g i = ( ni ) 2 tan α i . (46)

Substitution into the prime-gap decomposition

P n =2n+ i=1 n1 ( ni ) g i (47)

gives (43).

This representation is exact since each angle is defined from the corresponding gap. The angle does not predict the gap. The gap defines the angle, and the triangle records the weighted contribution of that gap to the finite prime sum.

For n=6 , the gaps are

g 1 =1, g 2 =2, g 3 =2, g 4 =4, g 5 =2. (48)

The corresponding multiplicities are

h 1 =5, h 2 =4, h 3 =3, h 4 =2, h 5 =1. (49)

Geometric encoding is recorded in Table 3. The final column is the contribution h i 2 tan α i , which is equal to h i g i . The table shows that the trigonometric form reproduces the same exact arithmetic contribution as the gap formula.

Table 3. Geometric encoding for P 6 .

i

g i

h i =6i

tan α i = g i / h i

h i 2 tan α i

1

1

5

1 5

5

2

2

4

1 2

8

3

2

3

2 3

6

4

4

2

2

8

5

2

1

2

2

The final column in Table 3 sums to

5+8+6+8+2=29. (50)

Adding the baseline term 2n=12 , we obtain

P 6 =12+29=41. (51)

This agrees with the direct sum

2+3+5+7+11+13=41. (52)

The geometric relation is most transparent in Figure 2. The vertical height is h i , the horizontal gap is g i , and the angle is chosen so that tan α i = g i / h i .

The weighted contribution is therefore h i g i , equivalently h i 2 tan α i . The gap g i is encoded as a slope relative to height h i =ni , and its contribution to P n is h i g i .

Figure 2. Right-triangle representation of one weighted prime gap.

6. Asymptotic Scale and Finite versus Infinite Summation

The identity

P n =2n+ i=1 n1 ( ni ) g i (53)

is exact for every positive integer n . It does not by itself give a new estimate for P n , but it is consistent with the known asymptotic theory of prime sums.

The prime number theorem implies

p n ~nlogn. (54)

Consequently, the partial sum of the first n primes satisfies the classical leading estimate

P n = k=1 n p k ~ 1 2 n 2 logn. (55)

This is a known asymptotic statement, not a consequence newly proved here.

The gap formula gives a finite way to read the same scale. Since g i = p i+1 p i , the exact identity (53) expresses P n through weighted forward differences of the prime sequence. As intuition only, one may think of a typical gap near p i as having size comparable to logi . Replacing g i by logi in the weighted sum suggests

i=1 n1 ( ni )logi. (56)

This heuristic sum has leading order

1 2 n 2 logn. (57)

The point is the weights in the finite identity have the same natural scale as the classical asymptotic estimate. The argument does not replace the prime number theorem and does not give a new proof of (55). Thus, the finite decomposition has the same dominant growth as the usual asymptotic estimate for P n .

The comparison of exact values of P n with the leading asymptotic scale 1 2 n 2 logn is plotted in Figure 3. The plotted ratio gives a numerical view of the known asymptotic relation and shows that the exact finite decomposition has the expected growth scale. The curve shows P n / ( 1 2 n 2 logn ) for finite n , with the horizontal line marking the asymptotic level 1.

Figure 3. Partial prime sums relative to the leading asymptotic scale.

We now separate the finite theorem from infinite summation. The series

k=1 p k (58)

diverges in the ordinary sense because

p k . (59)

Therefore,

2+3+5+7+ (60)

has no finite value as an ordinary convergent series. Similarly,

k=1 1 (61)

diverges in the ordinary sense.

Assigning a finite value to a divergent series requires a specified regularization method. Such methods have legitimate uses in analytic continuation, spectral theory, and mathematical physics. They do not turn a divergent series into an ordinary convergent sum. For this reason, the finite identity (53) is kept separate from any regularized interpretation of infinite prime sums. Any regularized treatment of

k=1 p k

would require its own definitions, convergence principles, and proofs. It is not part of the finite result proved in this paper.

7. Conclusions

This work gives an exact finite decomposition for the sum of the first n primes. If p n denotes the n -th prime and

g i = p i+1 p i ,

then the partial prime sum satisfies

P n = k=1 n p k =2n+ i=1 n1 ( ni ) g i .

which is an exact rearrangement of the partial prime sum. It does not by itself give new estimates for P n , new bounds for prime gaps, or a new proof of the prime number theorem. Its contribution is structural which shows how each consecutive prime gap enters the finite sum through the weight ni .

The same identity also has the geometric form

P n =2n+ i=1 n1 ( ni ) 2 tan α i ,

where

tan α i = p i+1 p i ni .

This form encodes each weighted gap as the slope of a right triangle. It preserves the same arithmetic information in geometric notation. The examples confirm the identity exactly for finite values of n . The asymptotic discussion shows that the decomposition is consistent with the classical scale

P n ~ 1 2 n 2 logn.

The finite theorem is also independent of any regularized infinite summation. The Ramanujan-inspired aspect of this work also lies in the organization of arithmetic information and partial prime sum is rewritten as a weighted history of consecutive prime gaps. Thus, the result proved here belongs fully to finite number theory.

Acknowledgements

We express our sincere respect for Srinivasa Ramanujan, whose work continues to influence how mathematicians think about arithmetic structure, partitions, summation and the order hidden inside numerical patterns.

Conflicts of Interest

The authors declare no conflicts of interest regarding the publication of this paper.

References

[1] Bateman, P.T. and Diamond, H.G. (1996) A Hundred Years of Prime Numbers. American Mathematical Monthly, 103, 729-741.[CrossRef]
[2] Shimada, K. and Koyama, S. (2025) Weighted Prime Number Theorem on Arithmetic Progressions with Refinements. Mathematics, 13, Article 2564.[CrossRef]
[3] Suzuki, M. (2025) On Variants of Chebyshev’s Conjecture. The Ramanujan Journal, 68, Article No. 95.[CrossRef]
[4] Ramanujan, S. (1915) Highly Composite Numbers. Proceedings of the London Mathematical Society, 2, 347-409.[CrossRef]
[5] Hardy, G.H. and Ramanujan, S. (1918) Asymptotic Formulae in Combinatory Analysis. Proceedings of the London Mathematical Society, 2, 75-115.[CrossRef]
[6] Nicolas, J. and Robin, G. (1997) Highly Composite Numbers by Srinivasa Ramanujan. The Ramanujan Journal, 1, 119-153.[CrossRef]
[7] Goldstein, L.J. (1973) A History of the Prime Number Theorem. The American Mathematical Monthly, 80, 599-615.[CrossRef]
[8] Axler, C. (2019) On the Sum of the First n Prime Numbers. Journal de Theorie des Nombres de Bordeaux, 31, 293-311.[CrossRef]
[9] Sinha, N.K. (2010) On the Asymptotic Expansion of the Sum of the First n Primes. arXiv: 1011.1667
https://arxiv.org/pdf/1011.1667
[10] Soundararajan, K. (2006) Small Gaps between Prime Numbers: The Work of Goldston-Pintz-Yildirim. Bulletin of the American Mathematical Society, 44, 1-18.[CrossRef]
[11] Vaidyanathan, P.P. and Tenneti, S. (2020) Srinivasa Ramanujan and Signal-Processing Problems. Philosophical Transactions of the Royal Society A: Mathematical, Physical and Engineering Sciences, 378, Article ID: 20180446.[CrossRef] [PubMed]

Copyright © 2026 by authors and Scientific Research Publishing Inc.

Creative Commons License

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