Posts I've Made

two zeros shows up in front because you add "0" when the decimal number not larger than your fraction.
See.. when you input 9. the first if-else check if the 9 larger than 32, if not you told the program add 0 into variable c, where it suppose to be left untouched. It is not strange then, there are two zeros in front.

There are several way to check whether you need to insert "0" or "1" into variable c. But I prefer using %. If I got remainder 1 then I insert "1", if I got remainder 0 I insert "0". you need re-check your way/algorithm/logic to convert decimal to binary.

Updated: I saw a similar thread like this and aks299921 have given you a good solution.

Yeah, the way to goal is a problem, testing one by one is not an option for big number. That's why you need help from math to get to the goal.

You cannot take the difference and then divide.. It will get you wrong answer EX : from 5 to 15, numbers divisible by 3 is (6,9,12,15). If you take difference and the divide you will get 3.3 .. It will become inconsistent if you do this. Because early you round down, and now you round up. Instead you need take detour. First find numbers divisible from 1 to 4, by round down 4/3 = 1. Then number divisible from 1 to 15, by round down 15/3 = 5. And take the difference, and you will get result 4.

Quote

how to remove the amount of numbers that are divisible by the sets {2,3},{2,5},{3,5},and {2,3,5}

To get how many number divisible by 2 and 3, divide N/2/3 or equal to N/6. Also same as for divisible by 3 and 5, divide N/3/5 or equal to N/15. for divisible by 2, 3 and 5, divide N/2/3/5 or equal to N/30.

Quote

I am lost now on how to remove the amount of numbers that are divisible by the sets {2,3},{2,5},{3,5},and {2,3,5}

Before to go to code, at least you need to understand how to get Union among those three sets. Venn Diagram may help you visualize how to get the Union of sets. Some part of those three sets are overlapping each other, right? (overlapping means, there are some members of a set included in other set). If you sum up the amount of numbers of all three sets, you will counting some 'member'(in your case the 'member' of sets is numbers) more than once. So to eliminate members counted more than once, you subtract intersection set {2,3}, {3,5}, and {2,5}. Until here, the middle part among the sets, intersection set {2,3,5} are totally eliminated. Because when you subtract intersection set {2,3}, {3,5}, and {2,5}, intersection set {2,3,5} also get subtracted. So, you need to add back intersection set {2,3,5}.

I think you do not need to count one by one. Try this : from 1 to 10, how many number divisible by 2? answer is 5. the shortcut is 10 / 2 = 5. So same as 3 and 5..

Updated:
Sorry I am misunderstood your assignment. To get how many number divisible by either 2,3 or 5 from 1 to 10.. first get how many number divisible by 2, answer is 5. then how many number divisible by 3 is 3. and how many number divisible by 5 is 2. Since some number divisible by 2 also divisible by 3 and 5. You need to compare and join. Remember when you learn set of number in mathematics? Venn Diagram? learn about mutual exclusive, join, something like that?

What you need is identify how many sets are there, and how each sets overlapping other sets. Then identify how to get whole sets exclude each overlapping region. example : Have Sets A (divisible by 2) and Sets B (divisible by 3), each contain 5 number (2,4,6,8,10) and 3 number (3,6,9), and those two sets overlapping a bit/a part (have some numbers exist/contained in each two sets)(6). And to get how many number divisible either by 2 or by 3, without counting a number twice, you do like this, Sets_A + Sets_B - Sets_A(intersection)Sets_B -> 5 + 3 - 1 = 7. Now your job is how to translate it into program code. Good luck!