Sum of numbers in an interval (2) X39837


Statement
 

pdf   zip

html

Write a funcion sum_interval(a, b, n) that receives two integers a,b such that 0≤ab, and a natural 0≤n≤9, and returns the sum of all integers in [a,b] whose last digit is n.

Sample session
>>> sum_interval(5,10,8)
8
>>> sum_interval(5,10,3)
0
>>> sum_interval(1,100,6)
510
>>> sum_interval(10,20,0)
30
Information
Author
ProAl
Language
English
Official solutions
Python
User solutions
Python