human
What is a code to sum of last digit of all integers from 1 to N divisible by M and the other steps required given the following:
Sum of last digit of all integers from 1 to N divisible by M | Function to return the required sum.
Number of element between 1 to n divisible by m.
Array to store the last digit of elements in a cycle.
Storing and adding last digit of cycle.
Number of elements present in last cycle.
Sum of k / 10 cycle.
Adding value of digits of last cycle to the answer.
Driver Code.
input n and m"
Solution in Python:
assistant
#Here is code to sum of last digit of all integers from 1 to N divisible by M and the other steps required.
 def sumOfLastDig ( n , m ) :
	sum = 0 ;
	k = n // m ;
	arr = [ 0 ] * 10 ;
	for i in range ( 10 ) :
		arr [ i ] = m * ( i + 1 ) % 10 ;
		sum += arr [ i ] ;
	rem = k % 10 ;
	ans = ( k // 10 ) * sum ;
	for i in range ( rem ) :
		ans += arr [ i ] ;
	return ans ;
if __name__ == " _ _ main _ _ " :
	n = 100 ; m = 3 ;
	print ( sumOfLastDig ( n , m ) ) ;