How many integers between $1$ and $1000$ are divisible by $2, 4,$ or $7?$

723 Views Asked by At

How many integers between 1 and 1000 are divisible by $2, 4,$ or $7?$

$A \cup B = A+B- A \cap B=500+142-71=571$

3

There are 3 best solutions below

0
On BEST ANSWER

Alternative solution:

Denote $A_n$ as the set of integers between $1$ and $1000$ divisible by $n$. Then you can blindly follow the inclusion-exclusion principle

$$|A_2 \cup A_4 \cup A_7| \\= |A_2|+|A_4| + |A_7| - |A_2 \cap A_4| - |A_4 \cap A_7| - |A_7 \cap A_2| + |A_2 \cap A_4 \cap A_7| \tag 1$$

Note that $A_2 \cap A_4 = A_4, A_4 \cap A_7 = A_{28}, A_7 \cap A_2 = A_{14}, A_2 \cap A_4 \cap A_7 = A_4 \cap A_7 = A_{28}$ so some of the terms in $(1)$ will cancel out and you don't need to calculate all of them.

Can you take it from here?

0
On

Hint: Find out how many numbers are divisible by $2$ and how many numbers are divisible by $7$. Note that $2 | 4$ and numbers are divisible by both $2$ and $7$ iff they're divisible by $14$ (why?). Find out which numbers are counted in both f the lists of multiples.

0
On

Not a 'real' answer, but it was too big for a comment. I think that you're looking for a solution without using a calculator or PC but maybe this gives some insight. I did only a quick search with the following bound: $1\le\text{n}\le10^3$.

I wrote and ran some Mathematica-code:

In[1]:=Clear["Global`*"];
\[Alpha] = 10^3;
ParallelTable[
  If[TrueQ[IntegerQ[n/2] || IntegerQ[n/4] || IntegerQ[n/7]], n, 
   Nothing], {n, 1, \[Alpha]}] //. {} -> Nothing

Running the code gives:

Out[1]={2, 4, 6, 7, 8, 10, 12, 14, 16, 18, 20, 21, 22, 24, 26, 28, 30, 32, 
34, 35, 36, 38, 40, 42, 44, 46, 48, 49, 50, 52, 54, 56, 58, 60, 62, 
63, 64, 66, 68, 70, 72, 74, 76, 77, 78, 80, 82, 84, 86, 88, 90, 91, 
92, 94, 96, 98, 100, 102, 104, 105, 106, 108, 110, 112, 114, 116, 
118, 119, 120, 122, 124, 126, 128, 130, 132, 133, 134, 136, 138, 140, 
142, 144, 146, 147, 148, 150, 152, 154, 156, 158, 160, 161, 162, 164, 
166, 168, 170, 172, 174, 175, 176, 178, 180, 182, 184, 186, 188, 189,
190, 192, 194, 196, 198, 200, 202, 203, 204, 206, 208, 210, 212, 214, 
216, 217, 218, 220, 222, 224, 226, 228, 230, 231, 232, 234, 236, 238, 
240, 242, 244, 245, 246, 248, 250, 252, 254, 256, 258, 259, 260, 262, 
264, 266, 268, 270, 272, 273, 274, 276, 278, 280, 282, 284, 286, 287, 
288, 290, 292, 294, 296, 298, 300, 301, 302, 304, 306, 308, 310, 312, 
314, 315, 316, 318, 320, 322, 324, 326, 328, 329, 330, 332, 334, 336, 
338, 340, 342, 343, 344, 346, 348, 350, 352, 354, 356, 357, 358, 360,
362, 364, 366, 368, 370, 371, 372, 374, 376, 378, 380, 382, 384, 385, 
386, 388, 390, 392, 394, 396, 398, 399, 400, 402, 404, 406, 408, 410, 
412, 413, 414, 416, 418, 420, 422, 424, 426, 427, 428, 430, 432, 434, 
436, 438, 440, 441, 442, 444, 446, 448, 450, 452, 454, 455, 456, 458, 
460, 462, 464, 466, 468, 469, 470, 472, 474, 476, 478, 480, 482, 483, 
484, 486, 488, 490, 492, 494, 496, 497, 498, 500, 502, 504, 506, 508, 
510, 511, 512, 514, 516, 518, 520, 522, 524, 525, 526, 528, 530, 532, 
534, 536, 538, 539, 540, 542, 544, 546, 548, 550, 552, 553, 554, 556, 
558, 560, 562, 564, 566, 567, 568, 570, 572, 574, 576, 578, 580, 581, 
582, 584, 586, 588, 590, 592, 594, 595, 596, 598, 600, 602, 604, 606, 
608, 609, 610, 612, 614, 616, 618, 620, 622, 623, 624, 626, 628, 630, 
632, 634, 636, 637, 638, 640, 642, 644, 646, 648, 650, 651, 652, 654, 
656, 658, 660, 662, 664, 665, 666, 668, 670, 672, 674, 676, 678, 679, 
680, 682, 684, 686, 688, 690, 692, 693, 694, 696, 698, 700, 702, 704, 
706, 707, 708, 710, 712, 714, 716, 718, 720, 721, 722, 724, 726, 728, 
730, 732, 734, 735, 736, 738, 740, 742, 744, 746, 748, 749, 750, 752, 
754, 756, 758, 760, 762, 763, 764, 766, 768, 770, 772, 774, 776, 777, 
778, 780, 782, 784, 786, 788, 790, 791, 792, 794, 796, 798, 800, 802, 
804, 805, 806, 808, 810, 812, 814, 816, 818, 819, 820, 822, 824, 826, 
828, 830, 832, 833, 834, 836, 838, 840, 842, 844, 846, 847, 848, 850, 
852, 854, 856, 858, 860, 861, 862, 864, 866, 868, 870, 872, 874, 875, 
876, 878, 880, 882, 884, 886, 888, 889, 890, 892, 894, 896, 898, 900, 
902, 903, 904, 906, 908, 910, 912, 914, 916, 917, 918, 920, 922, 924, 
926, 928, 930, 931, 932, 934, 936, 938, 940, 942, 944, 945, 946, 948, 
950, 952, 954, 956, 958, 959, 960, 962, 964, 966, 968, 970, 972, 973, 
974, 976, 978, 980, 982, 984, 986, 987, 988, 990, 992, 994, 996, 998, 
1000}

So, there are $571$ solutions. I found that, using the following code:

In[2]:=Clear["Global`*"];
\[Alpha] = 10^3;
Length[ParallelTable[
   If[TrueQ[IntegerQ[n/2] || IntegerQ[n/4] || IntegerQ[n/7]], n, 
    Nothing], {n, 1, \[Alpha]}] //. {} -> Nothing]

Out[2]=571

Extending the bound to $1\le\text{n}\le10^9$ gives $571428571$ solutions.