human
Sum of first N natural numbers which are divisible by 2 and 7 | Function to calculate the sum of numbers divisible by 2 or 7.
Driver code"
Solution in Python:
assistant
#Here is code to sum of first N natural numbers which are divisible by 2 and 7 and the other steps required.
 def sum ( N ) :
	S1 = ( ( N // 2 ) ) * ( 2 * 2 + ( N // 2 - 1 ) * 2 ) // 2
	S2 = ( ( N // 7 ) ) * ( 2 * 7 + ( N // 7 - 1 ) * 7 ) // 2
	S3 = ( ( N // 14 ) ) * ( 2 * 14 + ( N // 14 - 1 ) * 14 ) // 2
	return S1 + S2 - S3
if __name__ == ' _ _ main _ _ ' :
	N = 20
	print ( sum ( N ) )