human
Program to find the Nth Harmonic Number | Function to find N - th Harmonic Number.
H1 = 1.
loop to apply the forumula Hn = H1 + H2 + H3 ... + Hn - 1 + Hn - 1 + 1 / n.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to program to find the Nth Harmonic Number and the other steps required.
 def nthHarmonic ( N ) :
	harmonic = 1.00
	for i in range ( 2 , N + 1 ) :
		harmonic += 1 / i
	return harmonic
if __name__ == " _ _ main _ _ " :
	N = 8
	print ( round ( nthHarmonic ( N ) , 5 ) )