gaurav7infy wrote:how many multiples of 3 are present between -100 and 100?
Here's an alternative approach.
For this approach, all you need is one rule:
the number of integers from x to y inclusive equals y - x + 1
We're looking for the number of integers in the set {-99, -96, -93, . . . . 93, 96, 99}
Since they're all multiples of 3, we can write them as:
-99 = 3(
-33)
-96 = 3(
-32)
-93 = 3(
-31)
.
.
.
93 = 3(
31)
96 = 3(
32)
99 = 3(
33)
At this point, all we need to do is determine the number of integers from
-33 to
33 inclusive.
Applying our
rule, this equals 33 - (-33) + 1 =
67
Cheers,
Brent