mynameisdong Wrote:Hi all,
Just to make sure I understand the question -
We [(200-102) / 2] + 1 = 50 to get the number of even numbers within 102 - 200 inclusive correct?
If they asked for all the odd numbers, how would you go about finding how many odd numbers there are?
Only way I could think of was, (200-102)+1 to get the total number of numbers, and subtract that by 50 (# of even numbers..).
any other way to get this? Just wanted to know how to do this inside and out.
thanks!
i'll tell you the way i do it, which is much more intuitive and much less formula-based (i can't remember a formula to save my life): i just transform the numbers until i have gotten them to turn into a list of consecutive integers 1, 2, 3, ..., N.
so, with the evens from 102 to 200:
102, 104, 106, ..., 200
divide by 2 (since they're separated by 2; we want consecutive integers, which are separated by 1)
--> 51, 52, 53, ..., 100
subtract 50 (since we want the first integer to be 1)
--> 1, 2, 3, ..., 50
so there are 50 of them.
if you want to try this technique out, give it a shot on your own question with the odds.