4
$\begingroup$

I know you could find the number of even numbers (since they are a multiple of two). For example the number of even numbers between $11$ and $30$ will be $$n= \frac{28-12}{2} + 1 = 9 $$

I wanted to know is there a similar way to find the number of odd numbers b/w two extremes?

$\endgroup$
6
$\begingroup$

You can use the exact formula. What is number of odd numbers between $11$ and $30$?

$$n = (29-13)/2 + 1 = 16/2 + 1 = 9$$

Let's list them out to make sure $: 13, 15, 17, 19, 21, 23, 25, 27, 29.$ There are $9$ of them, so that is correct. By the way, your formula was calculated wrong. $$n = (28-12)/2 + 1 = 16/2 + 1 = 8 + 1 = 9 (12, 14,16,18,20,22,24,26,28)$$

$\endgroup$
  • 2
    $\begingroup$ Sidd's answer certainly gives you what you want, and if you understand the reasoning behind the formula for evens then you should be able to see why it works for odds too. But here's another way of thinking about it: Counting the number of odd numbers between 11 and 30 is the same as counting the number of even numbers between 12 and 31. $\endgroup$ – Brett Frankel Aug 6 '12 at 5:40
3
$\begingroup$

Method 1:

If you can find the number of numbers, and you can find the number of even numbers, ....

Method 2:

The number of odd numbers between 11 and 30 is the same as the number of even numbers between 12 and 31.

$\endgroup$
  • 1
    $\begingroup$ Ah, a breath of sanity ... $\endgroup$ – almagest Jul 8 '16 at 5:58
1
$\begingroup$

use the A.P formula for finding the number of terms...say for no. of odd numbers between 1 and 11.... nth term= first term+(n-1)(common difference)......(*),where n=no. of terms,which we have set out to find in this case.

from (*) we have n= {(nth term-first term)/common difference}+1.....

For our problem, n= {(11-1)}/2}+1 =6

here common difference is 2 as an odd number occurs by adding 2 to the previous odd number etc.,

$\endgroup$
1
$\begingroup$

If you use the formula $(b-a)/2 + 1$, then for some case it would give wrong answer.

Say, $a = 2$ and $b = 4$, so there is only one ODD nmumber between 2 and 4 (inclusive), and that is 3.

By using the formula, we get $(4-2)/2 + 1 = 2$, that is wrong; if we consider a small alter here, we will calculate the difference like this:

$Diff = (b - a) /2 + X$

Here $X$ will be either 0 or 1 depending on whether any one of the variables (a or b) is odd or not. If $a \mod 2 = 1 \lor b \mod 2 =1$, then $X$ will be 1, otherwise 0.

That should give correct answer.

$\endgroup$
0
$\begingroup$

To get count of odd or even numbers between a range, follow the process as below:

Correct the Range to start and end with inclusive numbers as per question and then use following formula :

(m - n)/2 + 1 where m is greater than n

Example:

All Odd numbers between 21 - 61

correct the range to make it inclusive of the numbers which make the range to 23 - 59 use the formula:

(59 - 23)/2 + 1 => 19

All even numbers between 21 - 61

correct the range to make it inclusive of the numbers which make the range to 22 - 60 use the formula:

(60 - 22)/2 + 1 => 20

$\endgroup$
-1
$\begingroup$

The Problem What is the number of EVEN or ODD integers between two numbers n and m?

(where m>n)

Solution:

  1. Recall the formula (m-n+1)/2
  2. Calculate it.
  3. See below for how to interpret:

    • If m&n are mixed signs*, you're done. That's your answer.
    • If m&n are the same as the target**, round up.
    • If m&n are different than the target, round down.

Details:

  • *mixed signs = one is even and the other is odd.
  • **"same as the target = if you're looking for evens, then whether m&n are both even. If you're looking for odds, then whether m&n are both odd.
$\endgroup$
  • $\begingroup$ This seems far more complicated than necessary. If the OP knows how to count evens, why not shift the interval 1 unit to the right, and count evens? $\endgroup$ – pjs36 Feb 20 '15 at 0:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.