Write a function file that accepts the values of r, a and n as arguments and uses a for loop to return the sum of the first n terms of the geometric series. test your function for a = 3, r = 1/2 and n = 10.