[]AS3 algorithm instance] Output 1 to the maximum number of n digits title: input number n, sequentially output from 1 the largest n bits 10 binary number. For example, input 3, the output 1, 2, 31 until the maximum 3 digits is 999. 】

Source: Internet
Author: User

Idea: If we were to fill 0 in front of the number , we would find that the N-bit all 10 binary number is actually N from 0 to 9 of the full array. That is to say, we arrange each digit of the number from 0 to 9, and we get all the 10 binary numbers.

1 /**2 *ch Storing numbers3 *n n Number of digits4 *index Count Value5 **/6 Private functionNum (ch:array,n:int,index:int):void7 {8   if(index==N)9     {Ten Trace (CH); One         return;  A     } -      for(vari:int=0;i<10;i++) -     { thech[index]=i; -Num (ch,n,index+1);  -     }           -}

[]AS3 algorithm instance] Output 1 to the maximum number of n digits title: input number n, sequentially output from 1 the largest n bits 10 binary number. For example, input 3, the output 1, 2, 31 until the maximum 3 digits is 999. 】

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.