Use recursion to determine the nth term of an arithmetic series. Parameters: starting term, common difference, n. The formula for the nth term is an = an - 1 + d.

Write a lambda that checks if a tuple of integers is a square.

Resources:

Class slides: __https://docs.google.com/presentation/d/1iC-GsI2-bK96kdQ32hbrf3g2BuOeObFAIWCFFZOsop4/edit?usp=sharing__

Class code: __https://replit.com/join/ywxsbaugeu-shravyas__

Contact Info:

__shravyassathish@gmail.com__ (mentor)

__kingericwu@gmail.com__ (TA)

__felixguo41@gmail.com__ (TA)

def function(start, diff, n):

print(f"start:{start}, diff:{diff}, n:{n}")

if n == 0:

return start

start = start - 1 + diff

return function(start, diff, n-1)

print(function(10, 3, 4))

#2

x = lambda a,b:a==b**2

print(x(4,2))

print(x(9,3))

print(x(10,5))

def nthTerm(first, diff, n):

return int(first) + (int(n)-1)*int(diff)

parameters = input("Please enter the starting term, common difference, and nth term of the arithmetic series, space seperated: ").split()

print(nthTerm(parameters[0], parameters[1], parameters[2]))

isSquare = lambda x, y : x**2 == y

print(isSquare(int(input("Please enter root of the square: ")), int(input("Please enter squared number: "))))

#1

def function(start, diff, n):

print(f"start:{start}, diff:{diff}, n:{n}")

if n == 0:

return start

start = start - 1 + diff

return function(start, diff, n-1)

print(function(10, 3, 4))

#2

x = lambda a,b:a==b**2

print(x(4,2))

print(x(9,3))

print(x(10,5))