5-digit numbers are constructed from the digits 1-9. Count how many numbers do not contain both 3 and 4.

Guest May 9, 2020

#3**+1 **

a=1;b=1;c=1;d=1;e=1;p=0; cycle:n= a*10000+b*1000+c*100+d*10+e;if(a!=3 and a!=4 and b!=3 and b!=4 and c!=3 and c!=4 and d!=3 and d!=4 and e!=3 and e!=4 and a!=b and a!=c and a!=d and a!=e and b!=c and b!=d and b!=e and c!=d and c!=e and d!=e, goto loop, goto next); loop:printn,", ",;p=p+1; next:e++;if(e<10, goto cycle, 0);e=1;d++;if(d<10, goto cycle, 0);e=1;d=1;c++;if(c<10, goto cycle,0);c=1;d=1;e=1;b++;if(b<10, goto cycle,0);e=1;d=1;c=1;b=1;a++;if(a<10, goto cycle,0);print"Total = ",p

OUTPUT =2520 such numbers. This computer code exlcudes ALL 3's and 4's completely. They do not appear anywhere in the 2,520 numbers, which are all different digits such as: 12567 , 12568 , 12569 , 12576 , 12578 , 12579......etc.

Note: You can generate all these numbers using permutations of: 7 nPr 5 =2,520 permutations, which is what the computer code does.

Guest May 9, 2020

edited by
Guest
May 9, 2020

#4**+2 **

But then it says "do not contain *both* 3 and 4", which could mean that there must not be 3 and 4 together.

Then we'd have to count for the ones with only a 3 or only a 4.

Guest who asked the question, please clarify the ambiguity.

Thanks.

hugomimihu
May 9, 2020