Let's analyze the following arithmetic sequence:


3, 18, 33, 48, 63, 78, 93, 108,....


Suppose we only knew that a sequence was arithmetic, the second term was 18, and the fifth term was 63.  Think about how we could determine the value of the 8th term.


Project 8: Variables 'n1', 'val1', 'n2', 'val2', and 'n' have been initialized.  There is also a working method called nthTerm.

These variables are based on some arithmetic sequence.

n1 is the term number for val1 (2 for the example explained above)

val1 is the first value given (18 for the example explained above)

n2 is the term number for val2 (5 in the example explained above)

val2 is the second value given (63 in the example explained above)

n is the term number for the value we are calculating (8 in the example above)

nthTerm(first, dif, n) returns the nth value of the sequence when the appropriate values are passed.  

example: nthTerm(3, 15, 4) would return 48 because 48 is the 4th value in the sequence that has 3 as the first value and 15 as the common difference.

Task: Appropriately assign the value of 'value' to correspond to the nth term of the sequence given (this value would be 108 for the example above).

**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