Using the digits 1, 2, 3, 4, 5, how many even three-digit numbers less than 500 can be formed if each digit can be used more than once?
a=1;b=1;c=2;p=0; cycle:d=a*100+b*10+c;if(d%2==0 and d<500, goto loop, goto next); loop:printd," ",;p=p+1; next:c++;if(c<6, goto cycle, 0);c=2;b++;if(b<6, goto cycle, 0);b=1;c=2;a++;if(a<10, goto cycle,0);print"Total = ",p
OUTPUT: 112 114 122 124 132 134 142 144 152 154 212 214 222 224 232 234 242 244 252 254 312 314 322 324 332 334 342 344 352 354 412 414 422 424 432 434 442 444 452 454 Total = 40 such numbers.
Five cannot be first ( to be less than 500)
2 or 4 must be last (to be even)
Position 1 4 possibles ( 1 2 3 4)
Position2 5 possibles (1 2 3 4 5)
sosition3 2 possibles (2 and 4)
4 x 5 x 2 = 40 possible numbers