Finding the next smaller and next larger prime number

Hey all, will this code help me find the next larger and next smaller prime number? I only ask because my main() isnt outputting anything, but everything looks fine there. So assuming I may have done something that didnt make sense here.
          //returns the next larger prime number
          long largerGetter = num;
          long lG = num + 1;
          while(largerGetter != 1)
               largerGetter = PrimeChecker.primeOrNot(lG);
               lG++;
          nextLargerPrimeNumber = lG;
          //returns next smaller prime
          long smallerGetter = num;
          long sG = num - 1;
          while(smallerGetter != 1)
               smallerGetter = PrimeChecker.primeOrNot(sG);
               sG--;
          nextSmallerPrimeNumber = sG;

JimmyV88 wrote:
Hey all, will this code help me find the next larger and next smaller prime number? ...If this isn't homework (which it probably is), use the BigInteger class to find a [next probable prime|http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigInteger.html#nextProbablePrime()] given a prime number or keep subtracting two from that given prime and check if that number is [(probable) prime|http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigInteger.html#isProbablePrime(int)] to find the previous prime.

Similar Messages

  • HT1178 I have set up Time Capsule to use with Time Machine.  When I open Time Machine it 'cannot find' the Time Capsule and I have the Select the Disk each time.  In the Next Backup tab it always says "When disk is connected" even though the disk is alrea

    I have set up Time Capsule to use with Time Machine but when I open Time Machine it 'cannot find' the Time Capsule and I have to 'Select the Disk' each time. In the Next Backup tab it always says "When disk is connected" even though the disk is already connected.

    Your pro doesn't matter.. I presume it is happily working.
    Your imac setup has got messed up because you changed from a local (my book being USB type I presume) to network drive. Did you do a clean install of Lion?
    Did you use the backup from the Pro on the imac? Otherwise I don't see how the Pro shows up in use previous disk. Where is Pondini when you need him??
    You cannot download Time Machine as an App and replace the current version. It is built into the OS.. the only way to do it is a clean install. Unfortunately that might be the only way around the issue.
    There is a number of issues that Pondini has covered in the setup issues of troubleshooting.
    This is the most relevant I think. http://pondini.org/TM/B6.html
    But look at the whole section B setup problems.
    http://pondini.org/TM/Troubleshooting.html
    If it was me, I would store all the info you need.. not using TM but using a straight copy of files.
    Then clean install Lion. I doubt any of these issues would exist if you had not installed Lion over existing setup or used a different backup.
    See if you can get Pondini to respond.. !!

  • I cannot find the next and previous button in iTunes get info menu? Is there anyone that has also experienced this problem that can help me please

    I cannot find the next and previous button in iTunes get info menu?
    Is there anyone that has also experienced this problem that can help me please
    I have the lates version of Itunes

    I have managed to figure out how to solve this problem, after looking around I saw a lot of people kept saying makesure it is list view however this still did not work, I found the only way for me get these buttons back was to change the Movie to a TV Show and only then did the "Next" and "Previous" button appear. Right Click> Get Info > Options > Media Kind and then Select TV Show, this is extremely inconvienent but the only way that I found that has worked so far.
    Hope this works for you too!!

  • Find the Next available date which is not necessarily the Maximum Date

    Morning folks!
    I am trying to find the next scheduled appointment date (Including any day after today) for a patient which may not be the maximum date for that person. I am trying to do this in Oracle Forms. My Query is working in SQL*Plus but is not working in Forms.
    FUNCTION get_next_sched_date(P_PATIENT_ID in varchar2) RETURN DATE IS
      v_next_scheduled_date   patient_visit.target_date%TYPE;
    BEGIN
      select next_target_date into v_next_scheduled_date
      from   ( select v.*, max(target_date) over (partition by patient_id) max_target_date,
                           lead(target_date) over (partition by patient_id order by target_date) next_target_date
               from   patient_visit v)
      where  patient_id = P_PATIENT_ID
      and    next_target_date >= SYSDATE
      and    max_target_date > next_target_date;
      return( v_next_scheduled_date );
    EXCEPTION
       when NO_DATA_FOUND then
         return(NULL);
    When I compile this in Oracle Forms, it gives me an Error.Encountered the symbol "(" when expecting one of the following: ,from.
    I also noticed that Oracle Forms is not liking keywords such as LAG and LEAD. I am working on Oracle Forms 9i.
    Any idea what I am doing wrong here? Thanks for listening to my Monday harping. :-)
    Forms [32 Bit] Version 9.0.4.0.19 (Production)
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit ProductionEdited by: Roxyrollers on Aug 27, 2012 8:43 AM
    Edited by: Roxyrollers on Aug 27, 2012 8:46 AM

    Thanks.
    For now, I have another simpler solution. I was just curious if the first way would have worked.
    select MIN(target_date) into v_next_scheduled_date from patient_visit v1
    where  patient_id = P_PATIENT_ID
    and    target_date >= SYSDATE
    and    target_date <= (select MAX(target_date) from patient_visit v2
                           where  v2.patient_id = v1.patient_id);Edited by: Roxyrollers on Aug 27, 2012 9:16 AM

  • Has anyone downloaded Yosemite and found that there are no ore scroll bars? I have to move the window (of any window, Skype window, browser window etc.) in order to find the scroll bar and then it disappears so fast I can't even use it.

    Has anyone downloaded Yosemite and found that there are no ore scroll bars? I have to move the window (of any window, Skype window, browser window etc.) in order to find the scroll bar and then it disappears so fast I can't even use it.

    Not sure why that was unchecked but good to know!
    Apple's new default (since at least a couple of OS releases back) is to have it off so OS X matches the behavior of an iPhone or iPad.
    I almost never need a scroll bar, and when I do, I just move over to the edge of the window when scrolling and a larger scroll bar appears.
    Yes, for the most part, users don't really need the scroll bar. That's what the scroll wheel on almost all mice is for. Saves the trip over to bar to physically grab and move it. But, I do like it on all the time regardless. That way (especially with a long article) I can just take a quick glance over to the bar to see about where I am on the page (a third of the way down? halfway?). Otherwise, I have to move the page just to make it appear to give me the same information.

  • How to get the Next Material Document Number

    Hi,
    Please let me know How to get the next Material Document Number using Functional Module,
    Material Document number are  in MSEG table.
    Regards,
    Ganesh

    Hi Ganesh,
    if you want the next matrial number then first of all you have to define it as a number range in transaction snro.After creating the number range you have to define the interval.
    now you can use your number range by calling the function module
    CALL FUNCTION 'NUMBER_GET_NEXT'
          EXPORTING
            nr_range_nr             = '01' " here you have to give the number range number which you have defined in number range
            object                  = 'ZPRODLOG' " Number Range
          IMPORTING
            number                  = wa_prod_error_log-seqnr " sequence number generated,in your case material number field
          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.
    each and every time next number will get generated .
    i hope this will help you.
    Thanks,
    Tanmaya

  • How can we find the most usage and lowest usage of table in Sql Server by T-SQL

    how can we find the most usage and lowest usage of table in Sql Server by T-SQL
    The table has time stamp column
    StartedOn datetime
    EndedOn datetime

    The Below query has been used , but the textdata column doesnot include the name of the table ServiceLog.
    SELECT
    FROM
    databasename,
    duration
    fn_trace_gettable('F:\Program
    Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Log\log_148.trc',
    default)
    WHERE
    DATABASENAME='ZTCFUTURE'
    AND TEXTDATA
    IS
    NOT
    NULL
    --AND TEXTDATA LIKE 'SERVICE%'
    order
    by cpu
    desc; 

  • I can't find the 2G, 3G and LTE options after updating to iOS8.1, can anyone help me with this? I'm using iPhone5s

    I can't find the 2G, 3G and LTE options after updating to iOS8.1, can anyone help me with this? I'm using iPhone5s

    I have check on my service provider about the correct APN settings, but unfortunately doesnt work still..

  • I have stored everything on my Macbook pro in a external hard drive (Time Machine)  Now that we have "wiped the machine" I am told I can start it over and load ontent--apps, docs, etc from the hard drive, just plug it in, find the time machine and what?

    I have stored everything on my Macbook pro in a external hard drive (Time Machine)  Now that we have "wiped the machine" I am told I can start it over and load ontent--apps, docs, etc from the hard drive, just plug it in, find the time machine and what?    I need to know what to highligh, what to click on. 

    hirogliffix,
    take a look at this Apple page — in particular, the “Restoring data from Time Machine backups” section and its “Restoring your entire system from a backup” subsection.

  • How do I find the image name and media_link for an ubuntu image in the Gallery?

    I am trying to create VM using Python API.  
    I have a custom Linux image:
    image_name = 'cloudN-Azure-20150205-os-2015-02-05'
    media_link = 'https://portalvhds10ssz63zgvb9g.blob.core.windows.net/vhds/cloudN-Azure-20150205-os-2015-02-05.vhd'
    When I used this image to create VM, it failed.
    I would like to use the ubuntu 1204 image in the Gallery.
    How do I specify the image_name and media_link in my Python code?  Basically, where and how do I find the image name and media_link for an image in the Azure image Gallery?
    Thanks in advance...

    hi sir,
    Did you try to use "List OS Image"? we can get the property form the results:
    result = sms.list_os_images()
    for image in result:
    print('Name: ' + image.name)
    print('Label: ' + image.label)
    print('OS: ' + image.os)
    print('Category: ' + image.category)
    print('Description: ' + image.description)
    print('Location: ' + image.location)
    print('Affinity group: ' + image.affinity_group)
    print('Media link: ' + image.media_link)
    print('')
    Please try it. Any questions or it doesn't work, please let me know.
    Regards,
    Will
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Dialog box says-"Bridge encountered a problem and is unable to read the cache. ... purge central cache" For one, I can't find the central cache and two, I've purged the cache in bridge. Shouldn't that help.

    Our Bridge has been acting very strange. It keeps giving a dialog box of "Bridge encountered a problem and is unable to read the cache. ... purge central cache" For one, I can't find the central cache and two, I've purged the cache in bridge. Shouldn't that help? There's just all kinds of weird stuff going on. I suppose it does have something to do with the central cache, so maybe someone can tell me where to find it.
    When I use the burn/dodge tool sometimes it drags and staggers and takes forever to complete whatever I'm burning/dodging. When I try to delete an image from the dock, it won't disappear but it won't display either.
    Any help would be appreciated.

    The Central Cache is the Bridge Cache.
    It's referred as the Central Cache to differentiate it from the individual folder's cache or even the individual image cache.

  • From which table I can find the "Class type" and "Class" of the material?

    From which table I can find the "Class type" and "Class" of the material?
    Thanks in advance for the answers....

    Hi,
    try following table
    KSSK     Material number to class     
    KLAS     Class description     
    KSML     Characteristic name     
    CABN/CABNT     Characteristic name description     
    CAWN/CAWNT     Characteristic name
    [http://www.sap-img.com/materials/classification-view-of-material-master.htm]
    [http://wiki.sdn.sap.com/wiki/display/ERPLO/FrequentlyUsedTables]
    Regards
    kailas Ugale

  • How to find the column name and table name with a value

    Hi All
    How to find the column name and table name with "Value".
    For Example i have value named "Srikkanth" This value will be stored in one table and in one column i we dont know the table how to find the table name and column name
    Any help is highly appricatable
    Thanks & Regards
    Srikkanth.M

    2 solutions by Michaels (the latter is 11g upwards only)...
    michaels>  var val varchar2(5)
    michaels>  exec :val := 'as'
    PL/SQL procedure successfully completed.
    michaels>  select distinct substr (:val, 1, 11) "Searchword",
                    substr (table_name, 1, 14) "Table",
                    substr (t.column_value.getstringval (), 1, 50) "Column/Value"
               from cols,
                    table
                       (xmlsequence
                           (dbms_xmlgen.getxmltype ('select ' || column_name
                                                    || ' from ' || table_name
                                                    || ' where upper('
                                                    || column_name
                                                    || ') like upper(''%' || :val
                                                    || '%'')'
                                                   ).extract ('ROWSET/ROW/*')
                       ) t
    --        where table_name in ('EMPLOYEES', 'JOB_HISTORY', 'DEPARTMENTS')
           order by "Table"or
    SQL> select table_name,
           column_name,
           :search_string search_string,
           result
      from cols,
           xmltable(('ora:view("'||table_name||'")/ROW/'||column_name||'[ora:contains(text(),"%'|| :search_string || '%") > 0]')
           columns result varchar2(10) path '.'
    where table_name in ('EMP', 'DEPT')
    TABLE_NAME           COLUMN_NAME          SEARCH_STRING        RESULT   
    DEPT                 DNAME                ES                   RESEARCH 
    DEPT                 DNAME                ES                   SALES    
    EMP                  ENAME                ES                   JONES    
    EMP                  ENAME                ES                   JAMES    
    EMP                  JOB                  ES                   SALESMAN 
    EMP                  JOB                  ES                   SALESMAN 
    EMP                  JOB                  ES                   SALESMAN 
    EMP                  JOB                  ES                   PRESIDENT
    EMP                  JOB                  ES                   SALESMAN 
    9 rows selected.

  • To find the latest date and time

    HI all,
    I have a Ztable which contains execution date and exe time.
    1) I need to find the latest date and time How  can we do this?
    2) In my program,I need to insert some values to date,time and status field in Ztable. How can I insert it directly into the table?
    for eg ZTAB-DATE = 010122006
            ZTAB-TIME = 12.20.20
          just INSERT ZTAB is enough or NOT????????????
    POINTS WILL BE REWARDED
    THANKS IN ADVANCE

    1) You can do a number of things, one you can get all of the relevant records and sort the internal table by date and time in decending order, then simply read the first record of the internal table.
    2) It depends on the key of the table. Say for example, you have a table like so.
    MANDT
    KEYFIELD
    DATE
    TIME
    If the key alreays exists, you can use the modify statement to update the record, if it dosn't exists, you need to use the INSERT statement to insert the records.
    data: xtab type ztable.
    xtab-keyfield = 'ABC'.
    xtab-date = '20070207'.  " or sy-datum
    xtab-time = '221600'.    " or sy-uzeit.
    insert ztable from xtab.
    Make sure to use internal fomat for DATE and TIME.
    Regards,
    Rich Heilman

  • Where can I find the current time and date of Time Capsule?

    I have a home network consisint of 2 x Time Capsules and 1 x Airport Express.  All is working fine.  I would like to set up access control for one machine connecting to the network and I can see I can do this under Access Control on the Airport Utility.  My question is where can I find the current time and date setting for these devices? 
    I can set them to use the time.apple.com server to set the time automatically, but I can't find where to see the current time and date of the device.  The only place I can see reference to the time and date is on the logs and statistics under the Advanced tab of the AirPort Untility.

    I don't think you can change the time and date on the TC itself, it just connects to a time server (and you set your own time zone).

Maybe you are looking for