How Many Numbers Between 250 and 380 Are Multiples of Both 2 and 7?

Join the discussion
Registration is free. Start your own thread to ask a follow-up.
7 replies · 2K views
Helicobacter
Messages
158
Reaction score
0
In a set of integers from 250 to 380, inclusive, how many are multiples of both 2 and 7?

Please tell me if I'm correct:

floor((380-250+1)/(7*2)) = 9

And in general is it always the floor of [cardinality]/[LCM]?
 
Physics news on Phys.org


Helicobacter said:
In a set of integers from 250 to 380, inclusive, how many are multiples of both 2 and 7?

Please tell me if I'm correct:

floor((380-250+1)/(7*2)) = 9
I get 10.
On problems of this nature, the best course is to do a sanity check on your formula to see if it gives the right results.
Helicobacter said:
And in general is it always the floor of [cardinality]/[LCM]?
 


Mark44 said:
I get 10.
On problems of this nature, the best course is to do a sanity check on your formula to see if it gives the right results.

What formula do you use to get 10?
 


Is there a more efficient way than brute force?

Also, what would you do if one of the numbers wasn't prime; search for multiples of the LCM in a given set?
 


Here's a formula that gives the correct result:
[tex]\frac{378 - 252}{14} + 1[/tex]

252 is the smallest multiple of 14 that is greater than 250. 378 is the largest multiple of 14 that is less than 280.

This would also work:
[tex]floor(\frac{380 - 250}{14}) + 1[/tex]
 


Thanks

Can you tell me whether your formulas are generalizable and whether the divisor is always the LCM of the two given numbers?
 


Helicobacter said:
Is there a more efficient way than brute force?
Probably. But brute force is superior to using a poorly-understood or incorrect formula that gives incorrect results.

This was a simple problem that took me all of a minute or two to list the numbers in the set, and count them. After I knew how many numbers there were I was able to come up with a formula that gave the same result.
Helicobacter said:
Also, what would you do if one of the numbers wasn't prime; search for multiples of the LCM in a given set?
That seems reasonable.