Project 25: Geometric Sequence Part 1

Intro Problem:  A piece of paper is .01 inches thick.  If we were to fold it in half, it would be .02 inches thick.  If we were to fold in half again, it would be .04 inches thick.

It would be physically impossible to fold the piece of paper 30 times.  However, if we could it would be 169 miles thick!!

What???

Here is the thickness after each fold:

0.01, 0.02, 0.04, 0.08, 0.16, 0.32, 0.64, 1.28, 2.56, 5.12, 10.24, 20.48, 40.96, 81.92, 163.84, 327.68, 655.36, 1310.72, 2621.44, 5242.88, 10485.76, 20971.52, 41943.04, 83886.08, 167772.16, 335544.32, 671088.64, 1342177.28, 2684354.56, 5368709.12, 1.073741824E7

10737418.24 inches is equivalent to 169 miles :)

5, 15, 45, 135, 405, 1215, ...

A geometric sequence is a sequence of numbers with a common ratio.  In the example above, the first value in the sequence is 5 and the quotient of any number in the sequence and the previous number in the sequence is 3. 

We would define the geometric sequence as:

firstVal  = 5

rat = 3 (which stands for the common ratio)

The fourth number in the sequence is 135.  Think about what the 10th number in sequence would be.


Project 25: Variables 'firstVal', 'rat' and 'n' have been initialized.

firstVal represents the first value in a geometric sequence (5 in the example above)

rat represents the common ratio of the geometric sequence (3 in the example above)

n is the term of the sequence we are finding (if n = 4, value = 135 in the example above)

Task: Appropriately initialize 'value', which represents the nth term of the geometric sequence given.

**If your code works for 5 test cases, you can enter your e-mail address

Universal Computational Math Methods:

pow(5,2) returns 25.0

abs(-3.0) returns 3

sqrt(49.0) returns 7.0