Array of Digits in a number sequence

Well, I have a series of number from 1-999,999. Now I want to put every digit of those numbers in a separate array. I know, that really doesnt make any sense. this is what i mean:
for example i have number from 1-20
The the array will look like this
{1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 2, 0}
therefore array[20]=5;
well, now I am trying to do this except, I am doing it with 1-999,999 instead of 20. I would really appreciate the help.
I already know that the size of the array that holds the separate digits from 1-999,999 is 5888889.
Here is what i have done:
public class NumberSeq
       public static void main (String[] args)
         int[] array= new long[5888889];
         for(int i=0;i<array.length;i++)
            for(int j=1;j<=999999;j++)
               String str = Integer.toString(j);
               if(j>9)
                  while(str.length()>0)
                     int num= Integer.parseInt(str.substring(0,1));
                     array=num;
str = str.substring(1,str.length());
i++;
array[i]=Integer.parseInt(str.substring(0,1));     
This is not my first attempt. I did many different attempts to make this work, but it always gave an exception.
Well the error is that, I am getting arrayindexoutofbounds exception. So :(. I would really appreciate any possible help.

Your problem was the use of that extra "i" loop rather than just incrementing the target array pointer as I have done. Try this:public class Test {
     public static void main(String[] args) {
          int[] array = new int[5888889];
          int i = 0;
          for (int j = 1; j <= 999999; j++) {
               String str = Integer.toString(j);
               while (str.length() > 0) {
                    int num = Integer.parseInt(str.substring(0, 1));
                    array[i++] = num;
                    str = str.substring(1);
}You were also unecessarily handling the last digit of each number by a special case, notice how I handle all the digits of each number the same way.
Regards,
Tim

Similar Messages

  • How do I remove a number sequence using batch rename

    Hi
    I know I've done this in the past but cannot seem to work it out today.
    I have a series of images "_####_[layercompName].png".  I would like to remove the underscores and numbers.  The underscores removal is easy, but how do I remove the numbers (####) when they are different for each filename?  I would like the end result to be [layercompName].png
    The reason I have these filenames in the first place is that I have run the photoshop script "layer comps to files", and this adds a number sequence prefix.  I have tried to alter the script following various instructions I've found from trawling the internet (this one included How do you remove the number sequence when exporting layer comps to files? CS6. Windows 8.) but without any luck.  So now I'm resorting to batch renaming in Bridge.
    Thanks!

    Here you go, taken straight from: DesignEasy: How to Remove Sequence Numbers and Empty Spaces When Exporting Layers and Layer Comps
    Run Adobe Bridge and navigate to the folder with exported files.
    Select all files which have sequence numbers.
    Go to Tools > Batch Rename.
    Choose: String Substitution from the first drop-down list in New Filenamessection. From the second drop-down choose: Original Filename. In the Find: text field type: _\d{4}_ (underscore, backslash, letter d, open bracket, number four, closed bracket, underscore). Leave Replace with: text field blank. Ensure that you have Replace All and Use Regular Expression checked as shown on the screenshot below.
    Click on the Preview button in the top right corner and ensure that files will be renamed as you want.
    Click on Rename button and you are done.
    In case you are first time doing this and you still have doubts if everything will work as expected, check Copy to other folder option when renaming files. This option is located near the top left corner under: Destination Folder.
    Another thing I want to mention is to remove everything that you have below String Substitution options. In case you see additional renaming options just click on minus (-) sign on the right side to remove them.
    How to remove/substitute empty spaces in the file name using Adobe Bridge
    It is pretty similar process. The only difference is that you should type: \s (backslash followed with letter s) in the Find: text field. You can leave Replace with: text field blank or to type underscore.

  • MT940 format on Statement Number/Sequence Number

    Hi Expert,
    I have the following EBS source file, which has 2 sequence numbers:
    As you can read that the section of :28C is the section of Statement Number/Sequence Number.  According to MT940 standard, as follows:
    This field contains the sequential number of the statement, optionally followed by the sequence number of the message within that statement when more than one message is sent for one statement.   The statement number should be reset to 1 on 1 January of each year.
    The sequence number always starts with 001. When several messages are sent to convey information about a single statement, the first message must contain '/001' in Sequence Number.
    One SWIFT message may contain up to 2000 characters.
    My source file's Statement Number/Sequence Number is correct, which caontains 1 statment (00006) and 2 sequence number which are: 00001 and 00002.  But during EBS upload using FF_5, system only managed upload first portion of the source file, and when come to second portion, 00006/00002, it always says ERROR: EBS (00006) already exist.
    But, based on MT940 standard, it should be OK.
    Therefore, does anyone have any idea why SAP FF_5 cannot handle the EBS source file upload?  Any further settings / configuration in order to hanlde Statement Number/Sequence Number?
    Thanks in advance
    sbmel

    Hello,
    I have encountered the same issue on MT940 with statement number/sequence number in field 28C.
    Our bank sends us MT940 into 17 separate files with sequence number for the same statement number (i.e. 13040/0001, 13040/0002..... and so on) while following the rule as below
    intermediate closing balance must have code :62M:
    and intermediate opening balance must have code :60M:
    finalclosing balance must have code :62F:
    and initial opening balance must have code :60F:
    However, the upload of first file in FF_5 terminated with error FV151 Termination in statement no.acct .... ; closing record 62F missing and subsequent files are with FV150 missing beginning record 60F.
    Would you please share your expertise on how you managed to make FF_5 accept these MT940 files with sequence number?
    Thanks in advance for your help on this.
    Regards
    Taro

  • Item Number Sequence - Wrong Order

    Hi Masters,
    I have a doubt about item number sequence on the screen.
    This is a example of my screen: [Item Data |http://www.sapsrm.xpg.com.br/SAP/QUOT.jpg]
    Why the sequence number are wrong? Have any note to solve this?
    Thanks,
    Pedro

    Thank you for the intention, but my SRM Server is the 550 and I already assists that note. 
    My SRM is the 5.5. 
    Some other idea?
    Thanks,
    Pedro Marques

  • How many digits in idoc number

    hi,
    please tell me how many digits in idoc number.
    regaerds
    subhasis.

    Hi,
    I believe it is 16 digits..
    Thanks,
    Naren.

  • Removing number sequence in 'Export layers to files" in CS5

    Hi the script automatically embeds a number sequence prefix to the exported layers, thus rendering your own file naming convention useless. Is there a fix for this? Perhaps the JS file can be rewritten? Or an option created called 'dont auto-renumber my files' or 'use layer names as file names".
    This is a similar thread, but for CS2, Im trying to get answers there too.
    http://www.photoshopcafe.com/cafe/viewthread.php?tid=34313
    The JS edits suggested there arent working for CS5.
    Please help becuase its almost as painful renaming the final files as it is to simply "file/save as", which makes this script useless.
    Cheers

    Hey Michael, hopefully I helped these guys out too, thanks to you:
    http://www.photoshopcafe.com/cafe/viewthread.php?tid=34313
    and
    http://forums.devshed.com/photoshop-help-88/removing-number-sequence-in-export-layers-to-f iles-in-cs5t-730612.html#post2507012
    Cheers again

  • EDI Control Number Sequence

    Does anyone has an idea about how the Control Number sequence can be maintained for the partners while doing mapping in XI??? Is it possible in XI.

    Hi,
    write UDF like this
    public String CNumber(String val,Container container)
    String val; Object obj;
    obj = container.getGlobalContainer().getParameter(val);
    if(obj == null) throw new RuntimeException (" exc occur");
    else
      val = obj.toString();
    return val;
    Give any input then it generates some Unique control number. In general we can give the input as Signal nummbers(ex : 850 or 855 or .......)

  • Set party number sequence with a specific value

    Hi all,
    I have a requirement to start the customer party number sequence from a specific number, so whenever a new customer is created the party number will be above a certain value. Any suggestions on how I can do that?
    Thanks, Mike.

    Thanks for the feedback. I got it with following SQL statements to start from 700000.
    alter sequence ar.HZ_PARTY_NUMBER_S increment by 700000 ;
    select HZ_PARTY_NUMBER_S.nextval from dual ;
    alter sequence ar.HZ_PARTY_NUMBER_S increment by 1 ;

  • Check number sequence - previous record variable

    Post Author: rmhogan
    CA Forum: Formula
    I am trying to highlight a record that is out of number sequence with the previous record.  I am guessing that I need to create 2 variables (one for the current number and one for the previous number).  I cannot seem to get this to work.
    Any help would be appriciated.
    Example ....
    Check Number
    016000123
    016000124
    016000126 <--- out of sequence (I want to highlight this detail line)
    016000127

    Post Author: rmhogan
    CA Forum: Formula
    Thanks so much.  However, I am getting a error saying  ... "The formula result must be a number".  The fields are strings in the database, however I have converted the to numbers in a formula  &#91;tonumber() function&#93;.
    Any ideas.

  • Indesign cc page number sequence

    I am using indesign cc! I want to change the page number sequence. Now we create the page number is auto setting left to right! But how can I change the view sequence right to left? Before I use cs5 it have the button on doc setting, now no this button, how can I do??

    I think this is ME feature.
    You can download indesign ME version, open the Creative Cloud app on your desktop. Then go to Preferences (On the top right corner) and under the "App Language" dropdown, select the version you want. Hebrew or Arabic that support english.

  • Check-digited Storage Unit number

    I have a client who wants to start using a check digited storage unit number.  Does SAP support such an option and if so, where can I find details on how it works?

    I have a client who wants to start using a check digited storage unit number.  Does SAP support such an option and if so, where can I find details on how it works?

  • Checking a number sequence with regular expressions

    Hello,
    Suppose I have a text in the pattern:
    A1=ha,A2=bla,A3=cha,...
    I don't know how many sections of "A#=$" (# denotes number, $ denotes text) will be in the text, but I want to verify that the numbers of the A's form the natural ascending number sequence (i.e 1,2,3,...). I prefer to use regular expressions to do this, but if there's another way, I will be glad to hear it too.
    Therefore my question is: How can I use regular expressions to check for a sequence of numbers? I know I can search for groups I've caught previously in the expression, but how can I compute the next number in the sequence from the group and search for the result?
    Thank you very much!

    What I'd do--and I'm not saying this is optimal, just what pops immediately to mind--is have a regex that matches "A(\\d+)=" (assuming the ha, bla, cha can never be "A1" etc.--if they can, you can still do it, but it's more complicated), then you iterate with the Matcher, and each time, you get the Integer.valueOf what you matched. You keep track of the last value, and compare the current to the last. If current is < last (or <= last, depending on your requirements), fail.
    Something like this. I don't recall Matcher's methods off the top of my head, so you'll have to fix the details.
    Matcher m = Pattern.matcher("A(\\d+)=");
    int maxSoFar = Integer.MIN_VALUE;
    while (m.matches(input)) {
        int current = Integer.parseInt(m.getMatchedField("$1"));
        if (current <= maxSoFar) {
            // fail
        else {
            maxSoFar = current;
    } maxSoFar =

  • Lost Digits of big Number - convert Double into Hex

    My Number is 24563383270390080
    if i debug the Variable it has got a value of 2.45633832703901e+016, so i lost a little bit of the value.
    if i bring ist into a sting, i can see the complete value "24563383270390080"
    i have to convert the number in to a Hex-Value, the Reuslt should be "$57444456503941" an can be written into a string.
    my problem is to bring the original value into a string of hex, because diadem round the last digits of my number
    i tryed several convertions, but the the probmel of lost digits is still there....
    maybe you´ve got an idea
    dim Number, NumberString, HexTest1, HexTest2, HexTarget
    Number = 24563383270390080  '17 Digits
    HexTarget = "$57444456503941"
    NumberString = Str(Number, "d")
    HexTest1  = Str((Data.Root.ChannelGroups("Neu").Channels("Vin_Data").Values(1)), "$")
    HexTest2  = Str(Val(Number), "$")
    '---> Result
    ''--> Number       = 2.45633832703901e+016
    '--> NumberString = "24563383270390080"
    '--> HexTarget  = "$57444456503941"  
    '--> HextTest1  =  $57444456503940  !!!!! Last Postion !!!!
    '--> HextTest2  =  $57444456503940

    You are a little bit out of luck with your example because
    dim number : Number = 24563383270390080 '17 Digits
    dim txt
    txt = txt & Str(Number, "d") & " ref: 24563383270390080" & VBCRLF
    txt = txt & Str(Number, "$") & " ref: $57444456503940" & VBCRLF
    MsgBox txt
     0 at the end is correct. (At least the MS calculator says so.) But this is by incident because of the number you picked.
    VBS only supports 64 bit double values. 64 bit doubles have a mantissa of 52 bits.
    24563383270390080
    becomes
    1010111010001000100010001010110010100000011100101000000
    which has 55 bit in use. Because your last bits aren't in use the number you picked can be represented by a double without loosing precission.
    24563383270390081
    would show the behavior you described because it is using 55bit range. The 1 is just cut when converted to double.
    But I have no solution for this because it will not work with VBS.

  • Custom Number Sequence

    Hi,
    I have got a requirement to have custom number range for notification.
    My requirements are:
    Number sequence YYYY-N
    YYYY- Year of Creation
    N - Numeric seqence 1,2,3,4,5,6,7............N
    Example: If a user creates a notificaton in the year 2009
    the numbers are 2009-1,2009-2,2009-3,2009-4...........2009-N
    and this counter restarts when a new year starts,
    so the number sequence for the year 2010 starts like
    2010-1,2010-2,2010-3,2010-4,......2010-N
    Is it possible to have this kind of number range in notification.
    Are there any BADIs or Userexits available to handle this.
    Please suggest me the approach
    Best Regards,
    Madhu

    Hi nanSieb,
    please refer the document: What is RowID/ROW_ID, and How is it Generated and Used? (Doc ID 476256.1) which will give you a better Idea to achieve your requirement.
    Thanks,
    Arjesh
    “Please mark any update as "Correct Answer" or "Helpful Answer" if that update helps/answers your question, so that others can identify the Correct/helpful update between many updates.”

  • How to generate a  number sequence for a column of a Z*table?

    Hi ,
    How to generate a  number sequence for a column of a Z*table?
    plz guide me.
    thanks
    Albert

    1) Use SNRO for defining a number range.
    2) Use FM NUMBER_GET_NEXT for getting the next number with object, sub object etc..
    See one example below.
          CALL FUNCTION 'NUMBER_GET_NEXT'
            EXPORTING
              nr_range_nr                   = c_01
              object                        = c_z_prd_code
    *           QUANTITY                      = '1'
             subobject                     = p_vkorg
    *           TOYEAR                        = '0000'
    *           IGNORE_BUFFER                 = ' '
           IMPORTING
             number                        = in_prd_code
    *           QUANTITY                      =
    *           RETURNCODE                    =
            EXCEPTIONS
                  interval_not_found            = 1
                  number_range_not_intern       = 2
                  object_not_found              = 3
                  quantity_is_0                 = 4
                  quantity_is_not_1             = 5
                  interval_overflow             = 6
                  buffer_overflow               = 7
                  OTHERS                        = 8
    3) You may write these code in main program of the table maintinence
    rgds,
    TM.

Maybe you are looking for

  • Macbook Air can't connect to VCFlex 10/100 via SFP Rj45

    I have USB-to-RJ45 connector, and I try to use it to connect to FIber Switch (VC Flex 10/100) via SFP RJ45. But I check the link is not detected, but if connect to normal RJ45 switch port it's working fine. Do anyone have the same problem like this,

  • Enter Tranfer posting(consignment to own stock)

    Hi, I want to compile a consignment Material to company's own stock. I used MB1B with the movement type 411 but a receive this error. Dlv. type (delv. type category OD for Material 86222 and BWART 411) cannot be determinated. Message no VL295. How ca

  • Re Usage limit

    Hi Please be gentle with me !!  I am not very good at this usage limi / allowance .  I have the basic package which I believe limits me to 10 gb of download per month . If i were to watch tv on my laptop ie catchup tv be it BBC or other very roughly

  • Field data in sm30 to be saved

    H

  • Abap cod e required  for  send an email with specific template

    hi guru's i want to send an email with specific template ,which contain some email links in the body of the email,and some of the font will be in different colour i want load the template it in to abap program as it is.is this possible. please let me