This writeup contains "sum of an infinite geometric series" and "sum of a finite geometric sequence".
Please note that because of limitations in HTML, the "math format" doesn't look perfect, and may even look messed up, depending on your browser.

Sum of an Infinite Geometric Series
long (written out) format
(summation of a times (r to the nth power), as n goes from to infinity) equals (a divided by (1 - r)), if and only if (the absolute value of r is between 0 and 1)

math format

Σ   arn
n = 0

=

a
--------
1 - r

iff

0 < |r| < 1

Sum of a Finite Geometric Sequence
long (written out) format
(summation of a times (r to the (i - 1) power), as i goes from 1 to n) equals (a times (1 - (r to the nth power)) divided by (1 - r))

math format
n
Σ   ari - 1
i = 1

=

1 - rn
a ---------
1 - r

The formula for the sum of a geometric sequence provides a great opportunity to illustrate different styles of proof.

The formula under discussion:

```a + ax + ax2 + ax3 + ... + axn = a*(1-xn+1)/(1-x)
```

The most obvious way to prove a formula of this sort (one with an n in it) is by mathematical induction:

```Step 1 (Show it's true for n=0):

a = a*(1-x)/(1-x)
Yup...  That's true.

Step 2 (Show that if it's true for n, it's also true for n+1):

a + ax + ... + axn + axn+1 =
(by assuming true for n)            a*(1-xn+1) / (1-x) + axn+1
(multiply by (1-x)/(1-x))         = a*(1-xn+1) / (1-x) + axn+1(1-x)/(1-x)
(add fractions)                   = (a-axn+1+axn+1-axn+2) / (1-x)
= (a-axn+2) / (1-x)
And that's what we wanted to prove.
```

Although this is often considered to be a perfect example of when to use mathematical induction, it's not as though it's particularly revealing of any deeper truths. And it's easy to miss a minus sign in the algebra involved, so if you forget the formula and need to derive it again, not only do you have to guess the right one, but you also need to get all the minus signs in the right place.

So, in this case, a direct proof is more illustrative:

```We'll call the sum we're looking for S, so
Let S = a + ax + ax2 + ... + axn
Then xS =     ax + ax2 + ... + axn + axn+1
So, if we subtract xS from S, we get:
S - xS = a                        - axn+1
Factor out the a on the right side, and then divide by (1-x):
S = a * (1-xn+1) / (1-x)
```

This proof even has a neat little mnemonic to help you remember the important step: "subtract off the excess (xS)". Okay, so it's not really that funny, but most puns aren't. At any rate, the math here is easier.

As an added bonus, it's really easy to get the sum of an infinite sequence from this formula. Just take the limit as n goes to infinity. There's only the one bit with an n in it (the xn+1). If the absolute value of x is less than 1, this goes to 0. Otherwise, it goes to infinity. We're interested in cases that don't go to infinity, so we're left with the formula

```  S = a * (1-0) / (1-x) = a / (1-x)
```
iff
```  -1 < x < 1
```

Below is a geometric progression calculator written in C.

It prompts the user to enter three numbers. The first number is the number you want the geometric progression to start with.

The second number is the multiplier, the number you want each successive number to increment by.

The third number is the number of integers you want in you progression.

The program should display the series and then present the sum.

If I have goofed on the terminology or the mathematics, please let me know, but I think it's OK.

``````
#include <stdio.h>
#include <math.h>

main()
{
int a, r, n, x, foo, sum = 0;

printf(" for your Geometric Progression Series.\n");

printf("\nThe first number should be the number");
scanf("%d", &a);

printf("\nThe second number should be what you want");
printf(" the series to increment by:\n");
scanf("%d", &r);

printf("\nThe third number should be the amount of numbers");
printf(" you want in the series.\n");
scanf("%d", &n);

for (x = 1; x <= n; x++)
{
foo = (x - 1);
int terms = (a * (pow(r, foo)));
printf("Term %d of the series is %d.\n", x, terms);
}

sum = a * ((pow(r, n) - 1) / (r - 1));

printf("\nTheir sum is %d.\n", sum);

return 0;
}
```
```

The proof that the formula Sn=(a(1-rn))/(1-r) sums n terms of a geometric series is as follows, where r is the ratio of the series (which is between -1 and 1) and a is the first term in the series.

Sn=ar0+ar1+ar2+...+arn-2+arn-1
(r)Sn=r(ar0+ar1+ar2+...+arn-1)
r*Sn=ar1+ar2+ar3+...+arn-1+arn
a+r*Sn=a+ar1+ar2+ar3+...+arn-1+arn
a+r*Sn=Sn+arn
Sn-r*Sn=a-arn
Sn(1-r)=a(1-rn
Sn=(a(1-rn))/(1-r)