human
Give me a code to find Nth term of the series where each term differs by 6 and 2 alternately and the other steps required given the following:
Find Nth term of the series where each term differs by 6 and 2 alternately | Function to find Nth term.
Iterate from 1 till Nth term.
Check if i is even and then add 6.
Else add 2.
Print ans.
Driver Code"
Solution in Python:
assistant
#Here is code to find Nth term of the series where each term differs by 6 and 2 alternately and the other steps required.
 def findNthTerm ( N ) :
	ans = 0
	for i in range ( N ) :
		if ( i % 2 == 0 ) :
			ans = ans + 6
		else :
			ans = ans + 2
	print ( ans )
if __name__ == ' _ _ main _ _ ' :
	N = 3
	findNthTerm ( N )