A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Generating Complicated Numbers Using Loops

Hybrid View

  1. #1
    Member
    Join Date
    Mar 2005
    Posts
    46

    Generating Complicated Numbers Using Loops

    --------------------------------------------------------------------------------

    Hi can any one help generating these numbers using loops

    1)

    ["000", "001", "112", "113", "224", "225", "336", "337", "448", "449", "5510", "5511", "6612", "6613", "7714", "7715", "8816", "8817", "9918", "9919"]

    2)

    ["000","001","001","002","003","114","115","116","1 17","228","229","2210","2211","3312","3313","3314" ,"3315","4416","4417","4418","4419","5520","5521", "5522","5523","6624","6625","6626","6627","7728"," 7729","7730","7731","8832","8833","8834","8835","9 936","9937","9938","9939"]

    Thanks in advance.

  2. #2
    Junior Member
    Join Date
    Sep 2004
    Location
    Sweden
    Posts
    8
    Hi!
    For the first array you can use this:
    Code:
    var i=0, j=0, ar=[];
    for(i=0;i<10;i++){
    	for(k=0;k<2;k++){
    		ar[j] = Number(String(i*11)+String(j++));
    	}
    }

  3. #3
    Junior Member
    Join Date
    Sep 2005
    Posts
    10
    Basic looping:

    1)

    for (i = 0; i <= 19; i++) {
    var j = Math.Floor(i / 2);
    var c = j.toString(10);
    var result = c + c + i;
    }

    2)

    for (i = 0; i <= 24; i++) {
    var j = Math.Floor(i / 4);
    var c = j.toString(10);
    var result = c + c + i;
    }

  4. #4
    Junior Member
    Join Date
    Sep 2004
    Location
    Sweden
    Posts
    8
    ... and if there's a typing-error causing the duplicate numbers at pos 1-2 in the second array:
    Code:
    var i=0, j=0, ar=[];
    for(i=0;i<10;i++){
    	for(k=0;k<4;k++){
    		ar[j] = Number(String(i*11)+String(j++));
    	}
    }

  5. #5
    Member
    Join Date
    Mar 2005
    Posts
    46
    Thankyou verymuch for all and your precious time.All These are working Fine

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center