if a number divisible by bougth number, if and only if , this number are multiple of lcm . so find lcm , and chak how many multiple have in this reange . ans = ( r/lcm) + (l-1)/lcm ; and if lcm > r so ans = 0;