Code for find the missing number in array without sorting/comparing in java

Hi all,
We have 1 to 100 number in an array, but one number is missing (from 1 to 100). we have to find it out without sorting or comparing of this missing number in array.
please help me out to find the solution this query.
regards & thanks
Mohan Kumar
Bangalore,
India

Maybe you could sum up the numbers you've got in your array and subtract the result from 5050 [the term [code](N*N+N)/2 where N is your upper bound (i.e. 100)]. You'll get the sum of all missing values (which in this case would be exactly the missing number). n.b. that you could genaeralize on that for arbitrary finite series.
Kind Regards,

Similar Messages

  • Code for finding the factorial of a no

    program  for finding the factorial of a no........

    hi
    the following are the 2 different codes  for factorial
    PARAMETERS:
      P_NUMBR TYPE I.
    DATA:
      W_FACT TYPE I VALUE 1,
      W_TEMP TYPE I.
    W_TEMP = P_NUMBR.
    DO P_NUMBR TIMES.
      W_FACT = W_FACT * W_TEMP.
      SUBTRACT 1 FROM W_TEMP.
    ENDDO.
    WRITE: W_FACT.
    USING MACROS
    DEFINE FACTORIAL.                      " Define macro
      DO 5 TIMES.                          " Do 5 times
        IF &1 GT 5.
          EXIT.
        ELSE.
          &2 = &1 * &2.
          WRITE: /'The factorial of &1 is'(001),&2.
        ENDIF.                             " Endif
        &1 = &1 + 1.
      ENDDO.                             " Enddo
    END-OF-DEFINITION.
    DATA:
        w_fact TYPE I VALUE 1,             " Factorial
        w_temp TYPE I VALUE 1.             " Temp
    FACTORIAL w_temp w_fact.
    regards,
    kiran kumar k

  • Finding the missing number from the table

    I have vendor table with the following column, refvendor_id, the refvendor_id is a primary key in the table. the customer use the application to enter information to the vendor table using an interface
    created in Java. my question is how can I query the refvendor_id numbers that have been skipped by the customer when they enter information to the vendor table.
    refvendor_id is a varchar data type.
    for example
    refvenodr_id
    1
    2
    3
    5
    6
    9
    I would like to capture in my sql the refvendor_id that is skipped here.
    4,7,8
    select refvendor_id
    from  vendor

    I suggest to find the number values with a regular expression.
    Here is a modified version, that will only use the pure number refvendor_ids
    -- Test-Data:
    with vendor as
    select '1' refvendor_id from dual union all
    select '2' refvendor_id from dual union all
    select '3' refvendor_id from dual union all
    select '5' refvendor_id from dual union all
    select '6' refvendor_id from dual union all
    select '9' refvendor_id from dual union all
    select '10'  refvendor_id from dual union all
    select '12'  refvendor_id  from dual union all
    select 'A'  refvendor_id from dual
    -- Query:
    select rownum from dual connect by rownum <= (select max(to_number(refvendor_id)) from vendor where regexp_like(refvendor_id,'^[0-9]+$') )
    minus
    select to_number(refvendor_id) from vendor where regexp_like(refvendor_id,'^[0-9]+$')
    order by 1;(I produce output in number-format, because i want numeric ordering in output)
    Edited by: hm on 14.12.2010 13:32 :
    Of cause you can also use your restrictions, but I can't see if that are really only numbers:
    select rownum from dual connect by rownum <= (select max(to_number(refvendor_id)) from vendor where SUBSTR (refvendor_id, 1, 1) IN ('1', '2', '3', '4', '5', '6', '7', '8', '9') AND LENGTH (refvendor_id) < 5 )
    minus
    select to_number(refvendor_id) from vendor where SUBSTR (refvendor_id, 1, 1) IN ('1', '2', '3', '4', '5', '6', '7', '8', '9') AND LENGTH (refvendor_id) < 5 )
    order by 1;

  • HT1459 I purchase an iPod shuffle for my niece and nephew last year for Christmas.  My nephew's iPod has come up missing and I have reason to believe it was stolen.  I  used my iTunes to put music on it in the beginning can I find the serial number somewh

    I purchased an iPod shuffle for my niece and nephew last year for Christmas.  My nephew's has come up missing and I have strong reason to believe it was stolen.  Amazon cannot give me the serial number and I used my iTunes to put music on it initially.  Is there a place I can find the serial number on my iTunes and can it be tracked to different computers if someone else is using it?  My nephew no longer has the packaging.

    Type "ipod serial number" into the search bar at the top of this page by Support and read the article explaining how to find the serial number.

  • How do I find the total number of elements in a multi dim array

    How do I find the total number of elements in a single or multi dim array?
    For example, a 2x3 array has 6 elements, and a 2x3x4 has 24. How do I compute this very easily - is there a single VI that does this?
    David
    Solved!
    Go to Solution.

    Use "array size" (array palette) followed by "multiply array elements" (numeric palette)
    (Works also equally well for 3D arrays and higher)
    For a 1D array, just use "array size".
    Message Edited by altenbach on 02-05-2009 05:57 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    NumberOfElements.png ‏3 KB

  • Where do i find the reference number for my preorder? and yes i no this is prob a dumb question but i cant find it anywhere......

    Where do i find the reference number for my preorder? and yes i no this is prob a dumb question but i cant find it anywhere......

        Hi droidboy52999,
    Your email won't have the same confirmation number as it was ordered over the phone. You will need the last name used for the order, the location code (this ends in 01) and an order number (five to six digit number). Please keep us posted if you need further assistance with this.
    Thank you,
    MariaC_VZW
    Please follow us on Twitter @VZWSupport

  • TS1702 Where can I find the serial number for my Logic Pro I just bought?

    Where do I find the serial number for Logic I just bought

    If you purchased it from the Mac App Store, there is no serial number I'm aware of. It's tied to your Apple ID rather than having a serial number or other key code.
    Regards.

  • Finding the minimum number greater than zero in an array

    Hi All,
    I have an Array (Attached). I need to find the minimum number that is NOT zero.
    Using the Array Max & Min returns 0 as the min. What I want is the next minimum number.
    Thank you.
    D
    Attachments:
    Array.jpg ‏72 KB

    Do you also need the position of the found element? What if several numbers have the same minimum value?
    If you just want the value of the smallest nonzero element,  here's what I would do. All you neet to do is retain is a single number.
    This assumes that your zeroes are really zero. With DBL you never know.  
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    SmallestNEZero.png ‏20 KB

  • I bought photoshop elements 13 at Costco for my Mac i cannot find the serial number anywhere on the box

    i bought photoshop elements 13 at Costco for my Mac i cannot find the serial number anywhere on the box

    You do not find a serial number ON the box where anyone may see the number
    Photoshop Elements is not part of the Cloud, I will move this to that forum
    Photoshop Elements Forum http://forums.adobe.com/community/photoshop_elements
    Redemption Code http://helpx.adobe.com/x-productkb/global/redemption-code-help.html
    Find serial # http://helpx.adobe.com/x-productkb/global/find-serial-number.html
    Select a topic, then click I STILL NEED HELP to activate Photoshop Elements Online chat
    -http://helpx.adobe.com/contact.html?product=photoshop-elements or
    http://helpx.adobe.com/photoshop-elements/kb/troubleshoot-installation-photoshop-elements- premiere.html

  • How can I find the serial number for my creative suite CS6 I bought it from a store.

    How can I find the serial number for my creative suite CS6 I bought it from a store.

    https://www.adobe.com/account.html for serial numbers or subscriptions on your Adobe page... or
    Lost serial # http://helpx.adobe.com/x-productkb/global/find-serial-number.html

  • How can I find the serial number from CS4 for my mac? I remembered it being on the box, but now I can't find it, and they website I thought to have registered it to doesn't recognize the e-mail I would have used then I got it.

    I don't know if this is the right place to ask this, but the website recommend I ask here. I bought the CS4 when I bought my macbook pro in when I was in college. I remember there being 2 serial numbers, so I could install to one other computer. That macbook pro finally died, and now I have a new mac which I am trying to re-install the creative suite on, only I can't find the serial number.  The two stickers on the back of the CS4 box (which i thought were the serial numbers) don't look like that they're asking for, and the website listed on the inside of the box for me to register to doesn't recognize my e-mail (which hasn't changed since buying CS4).  Any idea where I could find the serial number?

    To locate the serial number:
    http://helpx.adobe.com/x-productkb/global/find-serial-number.html

  • How do I find the serial number for a lost ipad?

    My ipad's been stolen, and I need to find the sertial nunber to give to the Police. Unfortunately, I did not keep the original packaging, so cannot refer to that for the serial number. I have an itunes account....am I able to locate my serial number through itunes, and if so, could anyone talk me through how I go about doing that. Many thanks.

    andybanham wrote:
    ....am I able to locate my serial number through itunes,
    Yes:
    Open iTunes on the computer you used to sync the iPad and select Preferences… from the iTunes menu. (In Windows, choose Edit > Preferences.)
    Select the Devices pane. Position the cursor over any of its backups. The iPad's serial number will appear in a popup window.
    For a screenshot read: iOS: How to find the serial number, IMEI, MEID, CDN, and ICCID number
    Scroll down to:
    Additional Information >
    Get the information from your computer >
    If you can access your computer, but not your device:

  • How do I find the serial number for my VirusBarrier Plus software downloaded from App Store

    I have dowloaded VirusBarrier  Plus software from the apps store and need a serial number to register. How do I find the serial number.
    Peter

    I would recommend contacting the vendor or maker of the software for support.

  • How do i find the serial number for my stole ipod touch on itunes

    My Ipod touch was stolen. I am trying to find out what the serial number for it is. Can I locate that anywhere on ITunes?

    This has more since an iOS devices like an iPod touch has more means than "dumb" iPods
    - iOS: How to find the serial number, IMEI, MEID, CDN, and ICCID number

  • How can I find the serial number for my stolen iPad that's associated with my apple ID ?

    How can I find the serial number for my stolen iPad that's associated with my apple ID ?

    If you registered it with Apple check your registered items at Your Support Profile for Registered Purchases. Also, see iOS- How to find the serial number, IMEI, MEID, CDN, and ICCID number.
    What To Do If Your iDevice Is Lost Or Stolen
    If you activated Find My Phone before it was lost or stolen, you can track it only if Wi-Fi is enabled on the device. What you cannot do is track your device using a serial number or other identifying number. You cannot expect Apple or anyone else to find your device for you. You cannot recover your loss unless you insure your device for such loss. It is not covered by your warranty.
    If your iPhone, iPod, iPod Touch, or iPad is lost or stolen what do you do? There are things you should have done in advance - before you lost it or it was stolen - and some things to do after the fact. Here are some suggestions:
    This link, Re: Help! I misplaced / lost my iPhone 5 today morning in delta Chelsea hotel downtown an I am not able to track it. Please help!, has some good advice regarding your options when your iDevice is lost or stolen.
      1. Reporting a lost or stolen Apple product
      2. Find my lost iPod Touch
      3. AT&T. Sprint, and Verizon can block stolen phones/tablets
      4. What-To-Do-When-Iphone-Is-Stolen
      5. What to do if your iOS device is lost or stolen
      6. 6 Ways to Track and Recover Your Lost/Stolen iPhone
      7. Find My iPhone
      8. Report Stolen iPad | Stolen Lost Found Online
    It pays to be proactive by following the advice on using Find My Phone before you lose your device:
      1. Find My iPhone
      2. Setup your iDevice on iCloud
      3. OS X Lion/Mountain Lion- About Find My Mac
      4. How To Set Up Free Find Your iPhone (Even on Unsupported Devices)

Maybe you are looking for