Example:
How many integers less than or equal to 20 are divisible by 2? 5? or 10?
20/2 = 10
2, 4, 6, 8, 10, 12, 14, 16, 18, 20
20/5 = 4
5, 10, 15, 20
20/10 = 2
10, 20
10 + (4/2)because every 2 numbers there is a even number - 2 = 10
____________________________________________________________
Now apply the same to 10,000
For your example question, you have the right answer, but the wrong reason.
10+4-2 = 12
Because you have counted 10 and 20 twice.
Thanks! Not gonna edit it because people can learn from my mistake.
a=0;b=0;c=0;d=0;p=0; cycle:n=a*1000+b*100+c*10+d;if(n%2==0 or n%5==0 or n%10==0, goto loop, goto next); loop:printn,", ",;p=p+1; next:d++;if(d<10, goto cycle, 0);d=0;c++;if(c<10, goto cycle, 0);d=0;c=0;b++;if(b<10, goto cycle,0);b=0;c=0;d=0;a++;if(a<10, goto cycle,0);print"Total = ",p
OUTPUT = 6,000 such integers.
Thanks for everyone's help! I really appreciate it. I got it. Have a nice day! :D