how many 7 digit phone number have their digits in non-increasing order? That is, every digit is either lower in value or equal in value to the previous digit.
a=1;b=0;c=0;d=0;e=0;f=0;g=0;p=0; cycle:n=a*1000000+b*100000+c*10000+d*1000+e*100+f*10+g; if(a<=b and b<=c and c<=d and d<=e and e<=f and f<=g, goto loop, goto next);loop:printn,", ",;p=p+1; next:g++;if(g<10, goto cycle, 0);g=0;f++;if(f<10, goto cycle, 0);g=0;f=0;e++;if(e<10, goto cycle,0);g=0;f=0;e=0;d++;if(d<10, goto cycle,0);g=0;f=0;e=0;d=0;c++;if(c<10, goto cycle,0);g=0;f=0;e=0;d=0;c=0;b++;if(b<10, goto cycle,0);g=0;f=0;e=0;d=0;c=0;b=0;a++;if(a<10, goto cycle,0);print"Total = ",p
OUTPUT = 6,435 such numbers.