# counting non-negative integers <100000 (studying for intro discrete math exam)

im studying previous math exams for my discrete math finals next week, no solutions are provided for past exams so i figured id try posting here.

Q: How many non-negative integers less than one hundred thousand, 100 000, contain at least one 2 and at least one 5?

A:

let $A$ be the set of all non-negative integers <100000 that do not contain a 2.

let $B$ be the set of all non-negative integers <100000 that do not contain a 5.

$$|A|=9^5$$ $$|B|=9^5$$ $$|A\cap B|=8^5$$

The number of non-negative integers <100000 that contain neither 2 or 5 is (by inclusion/exclusion): $$|A\cup B| = |A| +|B|-|A\cap B|$$ $$=9^5+9^5-8^5=85330$$

Thus, the number of non-negative integers <100000 that contain 2 and 5 is: $$100000-|A\cup B| =100000-85330=14670$$

• This answer agrees with a brute-force calculation. – Misha Lavrov Jun 4 '18 at 4:58
• I think we are going to be having exams together hehe.. (PW)(lukasz) Anyways, why is it to the power of 5 and not 6? – Mr Pro Pop Jun 4 '18 at 11:10
• @MrProPop Any nonnegative integer less than $100,000$ can be represented as a string of length $5$ by appending leading zeros as needed. – N. F. Taussig Jun 4 '18 at 12:09
• Your answer is correct. – N. F. Taussig Jun 4 '18 at 12:10