How many 4-digit numbers have the second digit even and the fourth digit at least twice the second digit? (Here, digits are read from the left, so the first digit is the leftmost digit, and so on.)
Answer is NOT 648.
When the 2nd digit is 0, then there are 80 such numbers =8 x 10 =80
When the 2nd digit is 2, then there are 60 such numbers =6 x 10 =60
when the 2nd digit is 4, then there are 20 such numbers = 2 x 10 =20
So, the overall total then is: 160 x 9 (from 1 to 9 in the first place) = 1,440 such numbers.
The following computer code verifies that:
a=1;b=0;c=0;d=0;p=0; cycle:n=a*1000+b*100+c*10+d;if(b%2==0 and d>=2*b and d!=0 and d!=1, 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 = 1,440 such numbers.