Reverse number

i'm using loops to reverse numbers and i have no clue on how to do it. i have to reverse the number using int. make the number 65000 into 00056

hi,
Probably you may also try this logic.
private static int palindrome(int original) {
          int reverse=0;int counter=0;
          int cloneOriginal=original;
          do {
               cloneOriginal=cloneOriginal/10;
               counter++;    
               }while(cloneOriginal >0);
          int temp[]=new int[counter];
          int increment=counter-1;
          do {
               int lastDigit=original % 10;
               original=original/10;
               temp[increment]=lastDigit;
               increment--;    
          }while(original >0);
          for(int i=0;i<temp.length;i++) {
               int base=1;
               for(int k=0;k<i;k++) {
                    base*=10;
               int multiply=base * temp;
               reverse+=multiply;
          return reverse;
Thanks
Prashant                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • Need help with a reverse number method

    hey all..
    i have this program which should return the integer reversed ..
    i have done this program using methods.. but the problem is if the
    number endes with 0 when it reversed the output doesn't contain the number 0
    for example:
    input
    123450
    output
    54321
    where before the 5 there should be 0
        This program that reads an integer and then calls a method
          that receives an integer and returns the integer with its digits reversed.
          Main prints the resulting integer.
       import java.util.Scanner; // program uses class Scanner
        class Sh9q4
           // main method begins execution of Java application
           public static void main( String args[] )
          // create Scanner to obtain input from command window
             Scanner input = new Scanner( System.in );
             int number; // The number entered by the user
             System.out.println("Enter an integer"); // prompt for input
             number = input.nextInt(); // read the the integer
             reverse (number); // print the method reverse
          } // end method main
           public static void reverse ( int num )
             int lastDigit; // the last digit returned when reversed
             int reverse = 0;
             do
                lastDigit = num % 10;
                reverse = (reverse * 10) + lastDigit;
                num = num / 10;
             while (num > 0);
             System.out.println("The integer with its digits reversed " + reverse); // print the integer reversed
          }// end method reverse
       } // end class Sh9q4thanks for your help :)

    If you need the leading zero to display, then you will have to do as Keith recommended and convert the input number to a String, then reverse that String and print it as a String.
    A number is a number is a numerical value, and there is no difference between the value of 054321 and 54321 except when written as a literal, when the first is an octal, and the second a decimal, value.
    If you are still confused, plug in these few lines of code and run them:String str = "012345";
    int x = Integer.parseInt (str);
    System.out.println(str);
    System.out.println(x);db

  • Require relationship between belnr and reversal number

    i want to know in which table the document number BELNR and its reversal order number are stored

    Hi,
    BELNR is being use in BKPF / BSEG  table
    and reverse document STBLG or STBLN in BKPF
    Regards
    Shiva

  • Why does InDesign always open multiple files in reverse number order?

    Whenever I select multiple InDesign files to open, despite being named accordingly Page_01, Page_02, Page_03, etc. InDesign always opens them in reverse order tabs. If I open 10 spreads at once instead of staring at page 1 I'm looking at the back.
    Is there any way to fix this? It's driving me mad. I cannot think of why it would be doing this.

    Create a book (File -> New -> Book...) and add your files to it. Rearrange the files to the order you want. Then select the needed files and double-click to open them. The tabs will be populated respecting the order the files appear in the book.
    Important: BEFORE adding the files to the newly-created book, go to the book panel menu, choose "Book Page Numbering Options..." and deactivate "Automatically Update Page & Section Numbers", to avoid unwanted renumbering of your pages.

  • Error while creating 2nd Material Receipt after reversal of 1st MR

    Dear,
    Facing an error while creating Material Receipt.
    The gate entry of this material is 123456789.
    The 1st MR was created on 10/02/2011 & no. was 12345 with Location ABC via Z T-code.
    Under Quality this product was Rejected with Location XYZ.
    Due to Material was Rejected in Quality this MR 12345 was reversed through MB01 which produced a Reversal number 67890.
    Now the material is again on its original Location ABC.
    Now when the user is again creating an MR on 17/03/2011 of this material present at ABC location via using Z T-code it is producing an error stating that M/R already processed against 123456789 gate entry.
    We have done these several cases before also and there was no error shown when we created the 2nd MR for the same material after its reversal has been made.

    Dear,
    Problem solved.
    The problem was in PO.
    The person had unchecked the GR-basediv which caused the real trouble. The MR number was not appearing in MB03 & material was rejected in the QA11 so it was reversed through MB01.
    When again the MR was being punched then it was stating that the "MR already processed for the Gate Entry."
    PO was changed, Bill No. was changed by adding "A" & later deleting this "A" from Table level.

  • Reversal FB08 Creating New OPEN ITEM instead of clearing the open item.

    Dear All,
    My user has an issue whenever he does any reversal  Tcode - FB08 in one of the general ledger  "Cash in Transit"  nature "open item" & "Line item"  instead of clearing the open it it  creates a new open line item.
    I have checked in Table BKPF , the reversal number is being updated but this items are still appearing open item in FBL3N and not appearing in F-04 (all reversals) for clearing.
    Can any one share what can be the reason its creating new open item  and how can i solve the issue for clearing the account.
    Thanks & Regards
    Pravin

    hi
    Please check following cases
    - whether this is happening in all the reversal cases of Cash in transit
    - Whether is user is just using FBRA (Onsly resetting) and not going for reversal
    - Chances would be one or two partial clearing may have taken for single document for the offsetting accounts
    Thanks
    Sandeep

  • Customer open iteam reversal

    HI Experts
    I have problem in customer  open iteams
    i am having open iteams on different dates in different years
    is it possible to reverse all open iteams at a same time
    what is the best way to reverse number of open iteams at a same time
    can any one give me a solution for my issue
    Thanks in advance

    Hi
    Goto T-code FB15
    select the customer and company code
    enter
    select the debit item and assign then confirm all execute to clear
    regards,
    ramanuja chary

  • Mail: how is the number # of each mail in a mailbox assigned?

    Hi there,
    Today I have finally transfered all my POP3-mailboxes into IMAP mailboxes.
    I did this by setting up new IMAP Accounts in mail and then just draging the old mails from the POP3-accounts into the new IMAP account.
    Now, strangely out of my 3 transfered mailboxes, in one mailbox the mails have a reverse number order and i want to fix it.
    Let me explain: in mail, in my inbox, i see a continuing number under the "#" sign for every mail. that number seems to be assigned according to the order oder which the mails have arrived.
    in the general inbox, everything is thrown together. So the numbers will look like this
    5763
    1
    2
    7382
    3401
    3402
    3
    3404
    4
    5
    That symbolizes different numbers from different accounts - well, i just would like to know, how i could sort of re-sort this particular mailbox, where the neweset mail has the number "1" - with all other mailboxes, the oldest mail has number "1", so i really wonder how that happened.
    Anybody knows what i am talking about? ;-)
    thanks
    btw of course i run lion 10.7

    u see this : http://help.sap.com/saphelp_nw04/helpdata/en/cf/21f2e5446011d189700000e8322d00/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21f2e5446011d189700000e8322d00/frameset.htm
    Madhavi

  • Create number range for Service Entry Sheet (SES)

    I would like it is possible to configure the number range for Service Entry Sheet (SES) or it is fixed in the system? Besides, for my current configuration, the number only appear when SES is done but no reversal number if I reversed the SES, is this a correct setting? Or is there any way I can set the number for reversal document?

    Hello,
    Check below SAP link.
    http://help.sap.com/saphelp_40b/helpdata/fr/77/e12c7dd435d1118b3f0060b03ca329/content.htm
    Hope it will help. Revert back if anyfurther question/s.
    Regards,
    Anup

  • What can I do to improve performance?

    CREATE TABLE temp_table
    ( ts timestamp
    , ttl NUMBER(5,0)
    , ipid NUMBER(10,0)
    , length NUMBER(5,0)
    , tid NUMBER(5,0)
    , cnxid NUMBER(10,0)
    , reverse NUMBER(1,0)
    , srcIp VARCHAR2(15)
    , srcPort NUMBER(10,0)
    , dstIp VARCHAR2(15)
    , dstPort NUMBER(10,0)
    , flags varchar2(10)
    , startSeq NUMBER(19,0)
    , endSeq NUMBER(19,0)
    , nbBytes NUMBER(5,0)
    , ack NUMBER(19,0)
    , win NUMBER(10,0)
    , urgent NUMBER(10,0)
    , options varchar2(500)
    CREATE TABLE mf1 NOLOGGING AS SELECT DISTINCT TS, TTL, IPID, LENGTH, TID, CNXID, REVERSE, FLAGS, STARTSEQ, ENDSEQ,NBBYTES, ACK, WIN, URGENT, OPTIONS from temp_table order by cnxid
    CREATE INDEX mf1_cid_idx ON mf1 (cnxid) NOLOGGING
    CREATE INDEX mf1_cid_ts_idx ON mf1 (cnxid,ts) NOLOGGING
    ANALYZE TABLE mf1 ESTIMATE STATISTICS SAMPLE 5 PERCENT FOR ALL INDEXED COLUMNS
    This is the function I would like to achieve better performance on, or rather it is the query in cursor c_query. I have a larger application that does a lot more, but we have found that the most time consuming part is doing the c_query on various cnxid so I figured a function like this would be a decent test to see how it performs without having to run the entire application.
    CREATE OR REPLACE FUNCTION test1 RETURN NUMBER AS
    CURSOR all_cid IS SELECT distinct cnxid FROM mf1;
    all_cid_row all_cid%ROWTYPE;
    sum_val NUMBER(19,0);
    CURSOR c_query(in_cid IN NUMBER) IS SELECT /*+ INDEX(mf1 mf1_cid_ts_idx)*/ * FROM mf1 WHERE cnxid = in_cid ORDER BY ts;
    c_query_row c_query%ROWTYPE;
    BEGIN
    sum_val := 0;
    FOR all_cid_row IN all_cid LOOP
    FOR c_query_row IN c_query(all_cid_row.cnxid) LOOP
    sum_val := sum_val+1 ;
    END LOOP;
    END LOOP;
    RETURN sum_val;
    END;
    I added a hint in the c_query for which index it should use. Without the hint it use mf1_cid_idx and performance is better with mf1_cid_idx.
    Runnig the SQL tuning advisory from enterprise manager I am told to analyse the table, which I though I did and to get another CPU.
    I have tried changing the analyse to this without any effect:
    begin dbms_stats.gather_table_stats(ownname => 'MARIUS', tabname => 'MF1', estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE, method_opt=>'FOR ALL COLUMNS SIZE AUTO'); end;
    I have tried clustering, but the way I insert tuples to the mf1 table achieve much the same as long as no new tuples are inserted. In other words when I tried clustering it I got the same performance.
    Another thing I have been wondering is that if I populate the mf1 table with 10MB 100MB 1GB 5GB the amount of time per MB of data decreases to a low point at 5GB and then dramatically increase if I populate the mf1 table with 10GB.
    The tablespace containing mf1 is 44GB large it only contains one incarnation of the mf1 table. It has a maximum 13GB used when I populate the mf1 with a 10GB table. temp is 8GB, undotbs1 8GB
    Any suggestion how I can imporve my c_query?

    I''m looking at the bulk transfer, actually I'm running tests to see how it perform. I was wondering if some one that was familiar with BULK transfeer could have a look at my new test1 function to see if it is equivalent to the old one. (Added the old one to the bottom for ease of reference).
    CREATE OR REPLACE FUNCTION test1 RETURN NUMBER AS
    TYPE number_table is TABLE OF mf1.cnxid%TYPE INDEX BY BINARY_INTEGER;
    cid_list NUMBER_TABLE;
    TYPE tab_table IS TABLE OF mf1%ROWTYPE INDEX BY BINARY_INTEGER;
    tuple_list TAB_TABLE;
    sum_val NUMBER(19,0);
    i NUMBER;
    ii NUMBER;
    BEGIN
    sum_val := 0;
    SELECT DISTINCT cnxid
    BULK COLLECT
    INTO cid_list
    FROM mf1
    ORDER BY 1;
    FOR i IN cid_list.FIRST .. cid_list.LAST LOOP
    SELECT /*+ INDEX(mf1 mf1_cid_ts_idx)*/ *
    BULK COLLECT
    INTO tuple_list
    FROM mf1
    WHERE cnxid = cid_list(i)
    ORDER BY ts;
    FOR ii IN tuple_list.FIRST .. tuple_list.LAST LOOP
    sum_val := sum_val+1 ;
    END LOOP;
    END LOOP;
    RETURN sum_val;
    END;
    CREATE OR REPLACE FUNCTION test1 RETURN NUMBER AS
    CURSOR all_cid IS SELECT distinct cnxid FROM mf1;
    all_cid_row all_cid%ROWTYPE;
    sum_val NUMBER(19,0);
    CURSOR c_query(in_cid IN NUMBER) IS SELECT /*+ INDEX(mf1 mf1_cid_ts_idx)*/ * FROM mf1 WHERE cnxid = in_cid ORDER BY ts;
    c_query_row c_query%ROWTYPE;
    BEGIN
    sum_val := 0;
    FOR all_cid_row IN all_cid LOOP
    FOR c_query_row IN c_query(all_cid_row.cnxid) LOOP
    sum_val := sum_val+1 ;
    END LOOP;
    END LOOP;
    RETURN sum_val;
    END;
    --- Edit, I get the following error trying this.
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    begin
    ERROR at line 1:
    ORA-04030: out of process memory when trying to allocate 16396 bytes (koh-kghu
    call ,pmuccst: adt/record)
    ORA-06512: at "MARIUS.TEST1", line 23
    ORA-06512: at line 2
    This is in the inner query. Do I have to reset or empty tuple_list between each iteration? How is this done?
    Message was edited by:
    Marius

  • Questions in Lync missed call notifications.

    Hello Experts,
    We have the following environment:
    Environment
    Currently there are no exchange UM’s in place.
    Has PBX to route the Enterprise calls.
    Missed call Behaviour
    When Lync receives the call, based on the calling number trunk translation rules the number is normalised and is presented with the missed call notification and Callee names will not be shown.
    What we are seeing here is a mixture, that when we get a call from the PBX, RNL is successful and I get the caller's picture, Name and E.164 number in the notification window for new call. But for the actual missed call notification,
    we only get the name (no number).
    Hence wanted to understand Lync missed call notification generation logic (where does it get the name from [RNL], which number does it show [called or AD], does it show the number etc ? ) as we are seeing mixed results with and without
    phone numbers or Names.
    Please advise. Thank in advance.

    Hi SBHV,
    Lync Server and Exchange Unified Messaging server are responsible to initiate a missed call notification. Lync Server generates a missed call notification by sending a SIP INFO message to Exchange unified messaging server, which in turn
    performs a reverse number lookup of the caller and sends email to the callee with the missed call details.
    During this reverse number lookup, if the incoming number is associated with any user or contact object on server (Exchange UM, Active Directory) or recipients personal contacts,
    it will be mapped with the caller or object name. If no match is found, just display the caller’s phone number or name. 
    Best regards,
    Eric.

  • StackOverflowError caused by conversion program

    Hello all,
    I'm a bit new to Java, so please bear with me if the answer to my problem is an obvious one.
    I am trying to write a program to convert numbers (floating and negative, too) from the given base to base 10. As this is part of a larger project, what i have already written will no doubt appear as overkill, but the code in question can be found at http://rafb.net/paste/results/YDpaXH25.html (the relevant section is bounded by 5 lines of asterisk comments on top and bottom). In any case, though the current code has no syntax errors, a runtime error does occur when i try to call it like so;
    // java code
    public class BasemathInterface {
    public static void main(String[] args) {
    Basemath a = new Basemath();
    a.convertBase(10, 23.4, false);
    //end java code
    a StackOverflowError:
    Exception in thread "main" java.lang.StackOverflowError
    Press any key to continue . . .
    I suspect this has something to do with line 88, where the second "half" of floating-point numbers are handled, since I've heard StackOverflowErrors are often caused by infinite loops, though i'm not sure how the current code would set up such a loop. Any help would be appreciated.
    Thanks in advance.

    Hello again . . . I changed the method a bit so that a StackOverflowError doesn't happen, but unfortunately that's because two "possible loss of precision error"s (num1 = convertBase(base, num1, false); num2 = convertBase(base, num2, true)) prevent the program from compiling . . . any ideas on why these happen and/or how to fix it would be appreciated.
         public double convertBase(int base, double num, boolean lessone) {
              int negflag = 0;
              int x;
              boolean conflag;
              String convert = "";
              if (contains(Double.toString(num), ".")) {
                   int dot = index(Double.toString(num), ".");
                   int num1 = Integer.parseInt(Double.toString(num).substring(0, dot));
                   int num2 = Integer.parseInt(Double.toString(num).substring(dot+1));
                   num1 = convertBase(base, num1, false);
                   num2 = convertBase(base, num2, true);
                   dot = index(Double.toString(num), ".");
                   num2 = Integer.parseInt(Double.toString(num).substring(dot));
                   num = Double.parseDouble(Double.toString(num1) + "." + Double.toString(num2));
              else {
                   String[] number =  new String[Double.toString(num).length()];
                   int[] inumber = new int[Double.toString(num).length()];
                   for (int i = 0; i < number.length; i++)
                        number[i] = Double.toString(num).substring(i-1, i);
                   if (lessone == false){
                        x = 0;
                   else {
                        x = -1;
                        reverse(number);
                   reverse(number);
                   for (int i = 0; i < number.length; i++) {
                        if (overten.containsKey(number)) {
                             conflag = true;
                             convert = number[i];
                             Integer ovr10 = (Integer)overten.get(number[i]);
                             number[i] = Integer.toString(ovr10.intValue());
                        else conflag = false;
                        if (number[i].equals("-")) {
                             negflag += 1;
                             remove(number, i);
                             continue;
                        else ;
                        if (Integer.parseInt(number[i]) < base) {
                             number[i] = Double.toString(Integer.parseInt(number[i]) * Math.pow(base, x));
                             if (!lessone)
                                  x += 1;
                             else x -= 1;
                        else {
                             if (conflag) {
                                  System.out.println("Numbers of Base " + base + " Cannot Have '" + convert + "' In Them.");
                             else System.out.println("Numbers of Base " + base + " Cannot Have " + number[i] + "'s In Them.");
                   for (int i = 0; i < number.length; i++) {
                        if (!lessone)
                             inumber[i] = Integer.parseInt(number[i]);
                        //else inumber[i] = Double.parseDouble(number[i]);
                   if (negflag % 2 != 0)
                        return -1 * sum(inumber);
                   return sum(inumber);
              return 1;

  • Called Name Doesn't Appear Until the Call Connects

    We have an issue with the Lync client and some of the Lync IP phones that if User A calls User B using his lineURI (extension number), the name of User B doesn't appear on User A's client until the call gets connected, in the meantime the extension only
    appears until the call gets connected.
    Any idea how to let the called name appear for the calling party?

    Yes that is what is address book normalization when the call comes into Lync It will normalize and then perform Reverse number look to display User information
    http://lyncuc.blogspot.in/2013/12/dialplan-normalization-with-extension.html
    http://blog.schertz.name/2010/09/lync-2010-address-book-normalization/
    Please remember, if you see a post that helped you please click "Vote As Helpful" and if it answered your question please click "Mark As Answer" Regards Edwin Anthony Joseph

  • How can  get an earlier version of my LDM ???

    Hi,
    we come to one issue:
    say we modify LDM at Nov 1th, and modify LDM at Nov 2th,but after commit what we did at Nov1th,and Nov 2th, we find there are 'mistakes' in Nov 2th,
    how can we get an earlier version of LDM?(in our case, we want revert to version Nov 1th).
    we use SDDM Version 3.1.1.703,and we share the project under subversion managed.
    more questions:
    (under subversion managed SDDM projet)
    1.what is best praise of backup in case we do something wrong and want rollback whole change to previous version?
    2.how to do that ,is there any document guide ?(I searched this forum, seems not find similar topic)
    Thanks,
    Jinbo

    Thanks Philip,
    now we can see the old reversion.
    but new issue comes.
    say two users:user1 & user2 are working on the LDM, and remote directory called LDM_remoate
    at Nov 2th,
    user1 have a latest local working copy under his machine directory LDM_local_user1
    user2 have a latest local working copy under his machine directory LDM_local_user2
    At Nov3th,
    user2 found some mistakes when user1 checked in at Nov 1th,so user2 want to get a earlier version say Nov 1 th,
    according to your guide, user2 get the design reversion number Nov 1th, and re check out at new working copy(Nov 1th) under new local directory:LDM_local_user2_new
    when user2 open LDM_local_user2_new, it indeed come back to version Nov 1th,
    but in the incoming change window, it still show many incoming changes,
    how to make the remote LDM_remote to become like LDM_local_user2_new? so that user1 only need check incoming change from LDM_remote as usual to make at local copy
    LDM_local_user1 also reverted to version Nov 1th?
    hope I make it clear to you.
    thanks,
    Jinbo

  • Is anyone else getting calls from Lagrange, GA? (706)594-**** area?

    I have been getting calls from:706-594-****, 706-594-****, 706-594-****, 706-594-****.  If I let it go to voice mail. They won't leave a message. and if I answer it they hang up. It's my belief that they are a service in determining if the line is active and what times you answer. Normally when I call them back I get a message that their voicemail box is full and I can't leave anything. But on the last attempt, I was able to reach 706-594-****, the man said he was out of the states and the call did not come from him because it would have been several $$/per min. and he claims someone must be using his number. (Are you getting this Verizon?) I did a reverse number look-up and found out these numbers are Verizon Numbers! Can't you put an end to this? Or as long as they're a paying customer.....they can do whatever they want to other customers?
    Please people, if you are being harassed by telemarketers, prank callers, spoofers (like the ones who call and caller ID says "000-000-0000") Speak up, speak out! let verizon know there is a problem. They need to make a Complaint Page. One where you can enter Problem numbers quickly. They can check it out, look at it's history and even block or invalidate his/her service if chosen to do so.
    I am on "do not call list". My number is unlisted. I don't give my number out. So the only way I'm getting calls is from an auto dialer or Verizon is leaking them out..
    All I know, I'm sick of it. Something needs to be done. We shouldn't have to pay a monthly service to add numbers to a blocked lists that blocks the numbers permanently and is limited to only 20. Nor the free service be limited to 5 and only lasts for a few months. Let's put our heads together and find something that works!
    NoiD™
    <Posted edited to comply with the Verizon Wireless Terms of Service.>
    Message was edited by: Verizon Moderator

    yah, insurance companies in general have you over a barrel and know it

Maybe you are looking for

  • SQL Query for TOP 10 Average CPU

    Have a SCOM Report request for a line graph showing top 10 average CPU for a group of servers. I have a query that will show all of the servers in a group for the last day, with the average CPU by hour. How can I extend the SQL query to only select t

  • EBS R12 Backup

    I am setting up backups for R12.1.1 on Linux x86-64bit with multiple nodes. To backup the apps and db (cold backup) weekly, i am using adstpall.sh, adstrtall.sh, addbctl.sh, addlnctl.sh for shutdown/startup apps and db. The question is can i wrap all

  • Statement not accessible error - Any ideas please.

    Hello all:           We were using macro from TRMAC table in 4.6C version and it used to give a warning but after upgrading to ECC6.0 it is syntax error! Please look at the code below: *SELECTION SCREN / PARAMETERS                                    

  • Microphone doesn't work for the phone app, but does for skype/heytell.

    So, my iphone4 randomly decided it would stop using the microphone when I made calls. I've tried using headsets/speaker mode but that doesnt change the fact the mic makes a single click sound and then I cannot be heard. I've installed the latest firm

  • Created a button to link to URL, need it to open a new window

    I created a PDF with several buttons. When the reader clicks the button it opens a URL. I need that URL to open in a separate window but I can't figure out how to do it. Any help would be greatly appreciated. Fernando