Prime factor problem

hey guys I got another java problem (go figure).
anyway heres the basic steps
1. take as input the path to a file containing one integer per line
2.for each integer in the file, output to the console a comma-delimited list of the integer's prime factors
3.the list of integers on each line of the output should multiply to produce the input integer
4.include unit tests for the code
basically im kind of at a loss of where to start. like is the first 1 asking me to ask for just one integer or as many as I put down?

well i changed that and tried to compile it but then it gave me this message. Class names 'primefactor' are only accepted if annonation processing is explicitly requested. heres the code.
public class primefactor
  public primefactor()
  public static void main(String[] args)
    primefactor factorEx = new primefactor();
    factorEx.FindAndPrint(50);
  public void FindAndPrint(int n)
    int totalCols=8;
    for (int i = 1; i <= n; i++)
      int countFactor = 0;
      for (int j = 2; j <= (i / 2); j++)
        if ((i % j) == 0)
          countFactor++;
      for (int j = 0; j < totalCols; j++)
        if (j <= countFactor)
          System.out.print(i+",");
        } else
          System.out.print(".");
      System.out.println();
}

Similar Messages

  • Prime factors

    Hello there, I'm trying to make a program to print the prime factors of an integer entered by a user. Also if the number is a prime factor more than once, it should be printed more than once. I have no idea to start other than the asking for an integer part. It's obvious that this requires for loops and such but I have no idea where to begin. Any help is appreciated.. tyty

    The following is not a full code, but you can complete..
    import java.awt.*;
    import java.awt.event.*;
    class FactFrame extends Frame{
         private TextArea ta;
         private TextField tf;
         public FactFrame(){
          setSize(460, 240);
          addWindowListener(new WindowAdapter(){
              public void windowClosing(WindowEvent e){
              System.exit(0);
         Panel p;
         add(p = new Panel(),"North");
         p.add(new Label("Integer"));
         p.add(tf = new TextField("",8));
         p.add(ta =  new TextArea(5,60),"Center");
         Button bt;
         add(bt = new Button("Factorization"),"South");
         bt.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent e){
              int a=2,n;
              StringBuffer result=new StringBuffer("");
              n=Integer.parseInt(tf.getText());
              for(;n>=a*a;){//this part would be replaced by "while(n>=a*a){"
              if(n % a==0){
    //   Here You Can Enter Your Algorithm
              n = n/a;//integer division
              else
              a++;
         StringBuffer sb = new StringBuffer(ta.getText());
         sb = sb.append(tf.getText());
         sb = sb.append("=");
         sb = sb.append(result.toString());
         sb = sb.append(String.valueOf(n));
         sb = sb.append("\n");
         ta.setText(sb.toString());
    public class Factorization{
         public static void main(String[] args){
              Frame w=new FactFrame();
              w.show();
    }

  • Prime number problem.

    I'm trying to create a simple program that tells me if the number entered is a prime number or not. I'm kind of stuck... I think it the problem is more with the math than the actual program itself. This is what I got:
    import java.util.*;
        public class Ch5Prg7
          static Scanner console = new Scanner(System.in);
           public static void main (String[]args)
              int num;
              System.out.println("Enter a positive integer.");
              num = console.nextInt();
              if (num == 1){System.out.println("That number is not prime.");}
              if (num == 2){System.out.println("That number is prime.");}
              if (num > 2){
              // not sure what to do here
       }Yeah, I know. It's not much. I just don't really know where to begin. Any help with the math or anything in general would be greatly appreciated. :)

    i believe the most efficient algorithm is to check every number less than or equal to the number in question, starting at 2. that is, for the number 9, try numbers up to 3 starting at 2. this could be implemented as following:
    boolean isPrime = false;
    if( num > 1 ) {                   //if this block is skipped, isPrime == false
       int root = Math.sqrt( num );   //store result to avoid calling every time through loop (every iteration)
       for( int divisor = 2; divisor <= root; divisor++ ) {
          if( num % divisor == 0 ) {
             isPrime = false;                 //number is NOT prime
             break;                          //no need to continue loop
    if( isPrime ) {
       System.out.println("That number is prime.");
    else {
       System.out.println("That number is not prime.");
    }Another algorithm you could use, although it may be slower due to the allocation of the array would be:
    boolean isPrime = false;
    if( num > 1 ) {                       //if this block is skipped, isPrime == false
       int root = (int)Math.sqrt( num );   //store result to avoid calling every time through loop (every iteration)
       bool[] possibleFactors = new int[ root + 1 ];
       //all array elements are initialized to false by the Java VM
       //false indicates untested value, true indicates tested value
       for( int divisor = 2; divisor <= root; divisor++ ) {
          if( possibleFactors[ divisor ] == false ) {
             if( num % divisor == 0 ) {
                isPrime = false;                   //number is NOT prime
                break;                            //no need to continue loop
             else {
                //set all multiples of divisor to true (indicating they were tested) since
                //none of the multiples will divide evenly if one of there factors didn't
                for( int i = divisor; i <= root; i += divisor ) {
                   possibleFactors[ i ] = true;
    if( isPrime ) {
       System.out.println("That number is prime.");
    else {
       System.out.println("That number is not prime.");
    }

  • Scaling factor problem in SAP Report Painter

    Hello,
    I am  designing reports using various scaling factors for column representation.
    The Scaling factor of 10 million is not working. It is observed that the scaling factor is working fine till 1 million i.e. 1,000,000.
    If the scaling factor is increased to 10 million (or above) i.e. 10,000,000 still the figures are scaled at 1 million only.
    Please let me know if any other settings have to be made to make this work as it is required in our reports to show figures in 10 million / 1 crore format. Attach below are the steps of a sample report to clarify the issue. Thanks.
    Details:
    Transaction:  GRR2
    Report name: ZFRPT5 (Fixed Assets note)
    Report Group: ZB05
    Path for setting the Scaling factor in the Report:
    Formatting => Columns=>Numeric format=>Scaling factor.
    Selection parameter (on execution): Fiscal year
    Have tried with many options. Would appreciate any help. Thanks.

    Hi,
    plese chek the given details .here i am getting 1 million formate
    formate group "0"
    coloumn formate
       coluoumn width - 17'
       Right margin - '0'
    Numerical formate
    scaling factor - '1'
    Decimial placesses - ' 0.00'.
    these are the settings for scaling formate. you will get 1 millions  as per this  settings
    please check.

  • Scaling Factor problem In BI

    Hi,
    I am facing scaling issue in BI queries.
    In 3.5 when i run a query  say $(dollar) symbol appearing in each and every cell ,But in BI it is not appearing as in 3.5 rather $(dollar) symbol is appearing on the Top of each and every column.Plz provide me Ur inputs to solve this.
    Thanks,
    SUbhash

    Hi Subhash,
    It looks like the "display scaling factor" option is switched on.
    There are two possible settings for this.
    1. The most common setting is in query. Check in Query Designer -> query properties.
    2. If you are running the query in web, the default web template may have the "display scaling factor" option switched on and also causes this.
    Go to transaction RSCUSTV27 to see whether "Ad Hoc Analysis" has a setting. This is the default template that gets used.
    If it's empty, then 0ANALYSIS_PATTERN is used.
    Change the parameter SCALING_FACTORS_VISIBLE in the default template to OFF to get the result you want.
    Regards,
    Patricia

  • Conversion factor problem for density - PP-PI

    Hi Gurus!
    Now  i am in pp implementation for  process industry.
    (Lubricants manufacturing Industry)
    1. On production of Semi Finished product each batch will be given a conversion factor where Raw materials will be consumed in KG and on MIGO (GR) output of Semi finished will be captured in Liters. In BOM for SKU (STOCK KEEPING UNIT) wise production it will be maintained in Liters.
    Now my area of concern are:-
    1. Conversion factor to be used at what stage & whether it is to be made flexible for each Process Order:   
       In proposed PP module it is being principally decided to undertake production of final FG in two stages. 
       First the production will be for product and in second stage it will be for the SKUs. The consumption of RAW materials will continue to be booked in KG. After the Blending is over when we do the GR for the Semi finished product the unit of measure should be in Liters ( that will depend on the Density after Blending)only.
       In Blending( Mixing of Base oil & Additive) operation the quality person will check the density (Kg/L)
    After applying the density he arrives semifinished quantity as detailed below:
    For Example  : semifinish  UOM  -
    Liter
                Raw mat1  qty   850Kg
                Raw mat2   qty  150kg
                        Total   =   1000kg
    Density of semifinish Material at 29.5deg C = 0..8957
    semifinish quantity  is  1000/0.8957 = 1116.45  Liter ( This is actual output)
    we need At the time of confirmation(COR6) the system will consume the raw material as 1000Kg and will give Semifinished qty as 1116.45  Liter
    How to map in SAP?
    Regards
    Ramrao

    Hi,
    You can handle this scenario by the use of Batch specific unit of measure.
    For Your Halb code use two unit of measure,
    - one which will be your Base Unit of measure - KG
    - Second will be your Production unit - Ltr,
    [ Batch Specific Unit of Measure|http://help.sap.com/bestpractices/BBLibrary/Documentation/Q24_BB_ConfigGuide_EN_US.doc]
    Now Do production / Confirmation and GR in KG.
    Insert MIC for Density where QA person do the test for Denstity.Use this MIC as a Link MIC so that value of MIC transfer to the Batch data of that Batch no. of that Halb code.
    With help of settings made in Batch specific unit of measure and dependency u will find stock in liters also.
    Regards,
    Dhaval

  • Premiere Elements12 "Online Content Download" problem ?

    Using Win7 64bit and have Adobe Creative Suite 4 Premium including Premiere Pro CS4 operating on same PC without any problems. Recently purchased from Adobe and downloaded PE12 as an upgrade from PE8.  Previously Premiere Elements 8 and CS4 operated same computer without problems
    On each occasion after I open PE12 and attempt to drag a audio or graphic file into the timeline, the programs stops to download an 18meg "online content download" before the audio or graphic file becomes active (after download) but only so long as  the program remains open. Have tried reinstalling PE12, same problem repeats.

    Daran66
    You can get All the Content of a particular category using the Download All option after you right click one of the thumbnails. Then it is a matter of whether or not you want to wait for the processes to complete with the project or opened or download in background with project opened.
    I have not found one button for a Download All and then wait for that to happen in the background or otherwise for All the categories including Instant Movie, Titles & Text, Audio, and Graphics. It has been one category at a time, re-starting the process to be described.
    Details if necessary.....
    Two prime factors in Content download and specifically the movie menus...
    a. Internet speed
    b. Status of Adobe Server
    What particular movie menu are you trying to download? All those questions being asked, please review the following being presented just to establish a baseline and try to address your question
    How do I tell PE12 to go get all of the content in one go or does it just do that in the background?
    In Premiere Elements 12, under Titles & Text Tab there are the choices for that category. You select the one you want and right click the blue ban at the top right of the selected thumbnail. From the pop up, you select Download Now or Download All.
    If I select Download All, I have found that All is referring just to the Content choices under Titles & Text and not all the categories that require this type of download, like Instant Movie, Titles & Text, Audio, and Graphics.
    When I select Download All, I get the following....
    If I click Yes, then I get
    And, I select Download in background if I wish to do something else while the process completes. Can take hours depending on Internet connection and Adobe server and Content to be downloaded.
    (I selected Titles & Text for this demo since I had already done the download for Tools/Movie Menu.)
    You wrote
    am unable to burn a DVD with any of the themes as they all seem to be stuck in some sort of "busy" grey rotating wheel state
    Have you looked at closing your large project (with Tools/Movie Menu left at no menu - Reset if you have applied the one menu that comes with the program without download required)
    Opening a new project and doing nothing but going to Tools/Movie Menu and doing the Content download using Download Now for the immediate need or Download All? Close out of that program...does not need to be saved. Open your large project and apply your movie menu.
    Does any of that work for you?
    ATR

  • How to find factors of number?

    I have a prime number program set up that finds prime numbers and to find two prime numbers beyond the number inputed. I also want to find the factors of the number inputed. I am brain freezed on finding the factors. For example I want to display 20 = 2 x 2 x 5, and for prime numbers I want to display 7 = 7. The factors will be displayed in label.
    I already have the first factor, but how do you continue to add factors to the string, that is going to be put into the label? I think it is a for loop in a for loop but not sure how to work it out??????
    here is my factor method
    private void factor(long value)   //bring in number from user
              long firstVal;
              String output = value + " = ";
                   for (long a = 2; a < 12; a += 1)
                        if (value % a == 0)
                             firstVal = value / a;
                             output = output + a + "x";
         }//factor-thanks

    Well that was to illustrate the point so that the person asking question can take correct direction.
    But you don't want to use your brain at all right.
    Then here is the code
    import java.math.*;
    import java.util.*;
    public class DirectSearchFactorization {
      private long max = 0;
      private Vector trialDivisors = null;
      private long nDivisions = 0;
      // Constructor
      public DirectSearchFactorization (long max) {
        this.max = max;
        // The trial divisors include all primes <= sqrt (n).
        // The trial divisors must also contain at least one
        // value such that d(k) >= sqrt (n).
        int sqrtn = (int) Math.ceil (Math.sqrt (max));
        trialDivisors = SieveOfEratosthenes.getPrimes (sqrtn);
        trialDivisors.addElement (new Long (sqrtn));
      public long getNumDivisions () {
        return nDivisions;
      // Get prime factors
      public Vector getPrimeFactors (long n) {
        if (n > max) {
          String s = n + " > " + max;
          throw new IllegalArgumentException (s);
        Vector factors = new Vector ();
        nDivisions = 0;
        // Step 1
        int k = 0;
        long divisor;
        Long divisorObj;
        long quotient;
        long remainder;
        // Step 2
        while (n > 1) {
          // Step 3
          divisorObj = (Long) trialDivisors.elementAt (k);
          divisor = divisorObj.longValue ();
          quotient = (long) Math.floor (n / divisor);
          remainder = n % divisor;
          nDivisions++;
          // Step 4
          if (remainder == 0) {
            // Step 5
            factors.addElement (new Long (divisor));
            n = quotient;
          else {
            // Step 6
            if (quotient > divisor) {
              k++;
            else {
              // Step 7
              factors.addElement (new Long (n));
              break;
        return factors;
    import java.util.*;
    public abstract class SieveOfEratosthenes {
      public static Vector getPrimes (int upTo) {
        int size = upTo + 1;
        boolean [] flags = new boolean[size];
        Vector primes = new Vector ();
        double limit = Math.sqrt (size);
        // Set flags
        for (int i = 2; i < size; i++) {
          flags[i] = true;
        // Cross out multiples of 2
        int j = 2;
        for (int i = j + j; i < size; i = i + j) {
          flags[i] = false;
        // Cross out multiples of odd numbers
        for (j = 3; j <= limit; j = j + 2) {
          if (flags[j]) {
            for (int i = j + j; i < size; i = i + j) {
              flags[i] = false;
        // Build list of primes from what is left
        for (int i = 2; i < size; i++) {
          if (flags) {
    primes.addElement (new Long (i));
    return primes;
    User Interface
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.Applet;
    import java.util.*;
    // The applet tests the DirectSearchFactorization class
    public class FactorizationApplet extends Applet {
    private Button factorButton = null;
    private Label numberLabel = null;
    private TextField numberTextField = null;
    private Label numDivisionsLabel = null;
    private TextField numDivisionsTextField = null;
    private Label factorsLabel = null;
    private TextField factorsTextField = null;
    private DirectSearchFactorization dsf = null;
    private static final long MAX = 500000;
    // Override Applet methods
    public void init () {
    Panel panel = new Panel ();
    panel.setLayout (new GridLayout (3, 2));
    numberLabel = new Label ("Number to Factor <= " + Long.toString (MAX));
    panel.add (numberLabel);
    numberTextField = new TextField ("387921", 25);
    panel.add (numberTextField);
    factorsLabel = new Label ("Prime Factors");
    panel.add (factorsLabel);
    factorsTextField = new TextField ("", 25);
    factorsTextField.setEditable (false);
    panel.add (factorsTextField);
    numDivisionsLabel = new Label ("Number of Divisions");
    panel.add (numDivisionsLabel);
    numDivisionsTextField = new TextField ("", 25);
    numDivisionsTextField.setEditable (false);
    panel.add (numDivisionsTextField);
    add (panel);
    factorButton = new Button ("Factor");
    add (factorButton);
    dsf = new DirectSearchFactorization (MAX);
    public void paint (Graphics g) {
    public boolean action (Event e, Object arg) {
    if (e.target == factorButton) {
    factor ();
    repaint ();
    return true;
    else {
    return false;
    private void factor () {
    long n = 0;
    factorsTextField.setText ("");
    try {
    n = Long.parseLong (numberTextField.getText ());
    if (n <= MAX) {
    Vector factors = dsf.getPrimeFactors (n);
    factorsTextField.setText (factors.toString ());
    numDivisionsTextField.setText (Long.toString (dsf.getNumDivisions ()));
    } catch (Exception e) {
    System.out.println (e.toString ());
    // Run as application
    public static void main (String[] args) {
    // Create frame to house the applet
    Frame frame = new Frame ("Factorization into Primes");
    // Create an instance of the applet
    FactorizationApplet app = new FactorizationApplet ();
    // Add it to the center of the frame
    frame.add (app, BorderLayout.CENTER);
    frame.setSize (450, 150);
    // Listen for window closing event
    frame.addWindowListener (new WindowAdapter () {
    public void windowClosing (WindowEvent e) {
    System.exit (0);
    // Call the applet methods
    app.init ();
    app.start ();
    // Set the frame visible
    frame.setVisible (true);

  • Problemi con aggiornamenti.

    Ciao ragazzi...vi espongo il mio problema.
    E' da qualche tempo...non saprei dirvi quanto di preciso...che dopo certi aggiornamenti di sistema che mi propone il mac dopo lìinstallazione e al riavvio mi da due errori (che poi sono gli stessi):
    L'estensione del sistema “/System/Library/Extensions/ZD1211Mac.kext” non è stata installata correttamente e non può essere utilizzata. Prova a reinstallarla o consulta il produttore per un aggiornamento.
    L'estensione del sistema “/System/Library/Extensions/ZD1211Mac.kext” non è stata installata correttamente e non può essere utilizzata. Prova a reinstallarla o consulta il produttore per un aggiornamento.
    qualcuno sa dirmi cosa possono essere???
    La diagnostica del mac mi ha detto che avevo un problema a qualche partizione del disco e gli ho fatto fare la riparazione, e ho fatto anche la riparazione dei permessi...non voglio aggiornare a Mountain Lion prima di capire se posso risolvere prima questo problema...non vorrei portarmelo dietro!!!
    Ringrazio tutti anticiptamente.
    Giuseppe

    Give us more infos, like mac model, os version and so on?

  • Square Root Help

    ok, I used the search function and had a hard time understanding how to do things and I don't think any of the posts answered my question.
    Right now, I am working on an assignment that makes me figure out the quadratic formula. I am having trouble with the square root part of the program.
    For instance that part is: sqrt( b*b - 4*a*c)
    I want my program to be able to tell if the square root is a perfect square then go ahead an calculate it, but if it is not, then we just want to reduce the square root function, or even if it is a perfect square, I need to make the program reduce fractions when possible.
    For instance, here is an example that is a perfect square: sqrt(25) = 5 , the program would just spit out five automatically.
    BUT
    If it were: sqrt(24), then I would want it to reduce it to 2 sqrt(6) and that is what the program would pop out.
    Also, I am having trouble on how to tell the program how to "reduce fractions" , because if I had the square root in the last example, I might be able to reduce fractions for the whole quadratic function.
    example. ( 2 - 2 sqrt(6) ) / 2              would reduce to   1 - sqrt(6) and that is what the program would say.
    basically it seems like we are avoiding actually dealing with decimals.
    If you could just point me in the right direction or have a good link, it would be appreciated!!!

    It seems to me your real problem is taking a number and finding all prime factors of that number. Once you have a list of those, you know you can pull duplicates out of the square root. If all of them were duplicates, you had a perfect square.
    Here's a simple program I scrawled out to factor and reassemble into the appropriate form:
    import java.util.*;
    class FactorTest {
        public static void main(String[] args) {
            int value = 96;
            LinkedList<Integer> factors = new LinkedList<Integer>();
            LinkedList<Integer> primeNumbers = new LinkedList<Integer>();
            populatePrimeList(primeNumbers);
            while (value > 1) {
               boolean factorFound = false;
               for (int prime : primeNumbers) {
                  if (value % prime == 0) {
                     value = value / prime;
                     factors.add(prime);
                     factorFound = true;
                     break;
               if (!factorFound) {
                  expandPrimeList(primeNumbers);
            int left = 1;
            int right = 1;
            int lastValue = 1;
            for (int factor : factors) {
               if (lastValue == factor) {
                  left *= factor;
                  lastValue = 1;
               else {
                  right *= lastValue;
                  lastValue = factor;
            right *= lastValue;
            System.out.println(left + " sqrt " + right);
        public static void populatePrimeList(LinkedList<Integer> primes) {
           primes.add(2);
           primes.add(3);
           primes.add(5);
           primes.add(7);
           primes.add(11);
           primes.add(13);
        public static void expandPrimeList(LinkedList<Integer> primes) {
           int testPrime = primes.get(primes.size() - 1);
           boolean foundFactors;
           do {
              foundFactors = false;
              testPrime += 2;
              for (int prime : primes) {
                 if (testPrime % prime == 0) {
                    foundFactors = true;
                    break;
           } while (foundFactors);
           primes.add(testPrime);
    }Edited by: jboeing on Jan 15, 2008 11:18 AM

  • How to add full screen text w/out losing audio. I have premier elements 12

    I am creating a language tutorial. Am trying to add full screen text without losing the audio explanation of the text. How do I make this edit and not lose the audio that coincides with the full screen text?

    Roberto
    Thanks for the details.
    Variable - Constant Frame Rate Explanation
    First, the variable frame rate mention and any problems that might be expected if your iPad video was recorded with a variable rather than constant frame rate. Some cameras (such a cell phone, iPod, probably iPad) record video not at one frame rate across the whole video recording. Instead, they record with a variable frame rate depending usually on the lighting conditions during video recording. One way to know what your recording device is using is to view the MediaInfo video audio properties readout. If you have a constant frame rate, you will see just one frame rate listed. If variable, you should see 3 frame rates listed minimum, maximum, and mid range frame rate.
    MediaInfo - Free download and software reviews - CNET Download.com
    This situation may or may not cause problems for you in Premiere Elements. The signs of problems are usually out of sync audio and you just cannot import the video into the project. If this type of problem, then you take your video into a program such as HandBrake to generate a file with a constant rather than variable frame rate. Then you import the file with the constant frame rate into your Premiere Elements project. http://handbrake.fr/
    Again, this may or may not create problems.
    The Generalized Project Workflow
    There is no problem to setup up your Timeline physically. The iPad video with go to Video Track 1 and Audio Track 1. The video is imported into the project linked to it audio portion. And, the Full Screen Text Files will be on Video Track 2 directly above the related content. Now here is the part that I am not yet clear on. Is the Full Screen Text for a given portion of video supposed to synchronize word for word with what you are saying in the audio on Audio Track 1? That will involve a mapping out part with regard to duration of each of the Full Screen Text files. Will these Full Screen Text files be readable against the video representing the background? Font style and size and color will be major considerations as well as getting the text file to be on screen long enough to be readable even with Font style, size, and color considerations.
    The fact that you focus on audio loss in all this makes me wonder if I am missing a vital part of what you want to do. The loss of audio concern that you mention does not seem like a prime factor unless you are referring to sync between the texts and what it is supposed to correspond to in the audio of the video.
    Please review and consider and then, based on your reply, I will offer a mini demo to see if we are OK on the details.
    Thanks.
    ATR

  • Can you write this program more efficiently?

    Hello :)
    I am trying to write a program that does the following:
    "The prime factors of 13195 are 5, 7, 13 and 29.
    What is the largest prime factor of the number 317584931803?"
    Since we are dealing with such a huge number, I've used the BigInteger class to handle it. But the problem is, the following code is inefficient..... I mean, its been calculating for the past 2.5 hours ;( I its still only on the 8th digit. I was wondering if someone could write this more efficiently?
    import java.math.*;
    public class euler6 {
         public static void main (String arhs[]){
               BigInteger a[]=new BigInteger[999];
               int j=0;
               BigInteger bi = new BigInteger("317584931803"); //*********
               BigInteger i=new BigInteger("2");
               final BigInteger one=new BigInteger("1");     
               final BigInteger zero=new BigInteger("0");     
               boolean state     ;
         for(;i.compareTo(bi)==-1;i=i.add(one))
              { //System.out.println(i);
                //System.out.println(bi.mod(i)+"*");
                //System.out.println(bi.mod(i).equals(zero)+"**");
                   if ((bi.mod(i).equals(zero))&& (findPrime(i)))
                        {a[j]=i;
                         j++;}
         for(int f=0;f<a.length;f++)
              System.out.print(a[f]+" ");
         public static boolean findPrime(BigInteger n){
                   final BigInteger one=new BigInteger("1");
                   final BigInteger zero=new BigInteger("0");
                   BigInteger x=new BigInteger("2");
                   for(;n.divide(x).compareTo(one)==1;x=x.add(one))
                        if (n.mod(x).equals(zero))          
                             return false;
                        return true;

    Hi,
    I agree with prev poster, you don't have to use BigInteger since long is sufficient.
    Try this, more optimized than initial version, yet still using brute force ... The drawback is, if the given number 317584931803 is a prime number .. then ... it will also take 24 hours to compute ... can't help that.
    My idea is, let's say I have number 30.
    So, I will search all possibility between 2 to 15. My reason is the factor will not exceed from 30 div 2 which is 15.
    While doing brute, I will decrease the iteration boundary.
    Eg:
    - 30 is succesfully devided by 2, then iteration will stop bruting force up to iteration #15.
    - next iteration, 30 is succesfully devided by 3, then iteration will stop bruting force up to iteration #10.
    - next iteration, 30 is succesfully devided by 5, then iteration will stop bruting force up to iteration #6.
    So, total there is only 4 iterations to check the factor of 30. And I get these number: 2, 15, 3, 10, 5, 6
    The next step would be checking which of the numbers are prime, and we get 2, 3, and 5.
    My algorithm is something like this:
    import java.util.*;
    public class PF // stands from Prime Factors ..
    public static void main(String s[]) throws Exception {
            long num = 317584931803l;
            List factors = new ArrayList(255);
            long div2 = (long) (num / 2);
            for (int i=2; i<=div2; i++) {
                    if (num % i == 0) {
                            div2 = (int) (num / i);
                            factors.add(new Long(i));
                            factors.add(new Long(div2));
                    Thread.yield();
            Iterator iter = factors.iterator();
            while (iter.hasNext()) {
                    long factor =  ((Long) iter.next()).longValue();
                    if (isPrime(factor)) {
                            System.out.println(factor);
    static boolean isPrime(long num) throws Exception {
            long div2 = (long) (num / 2);
            for (int i=2; i<div2; i++)  {
                    if (num % i == 0) return false;
                    Thread.yield();
            return true;
    }The reason I put Thread.yield() is so it won't hang your machine ... this happens if the big number you test is a prime number...
    My machine (Intel pentium III 700 MHz, 512 MB SDRAM) takes less than 1 second to compute ... ;-)
    Alex

  • Issues with premiere editor

    When I start up Adobe premiere elements 13, I have to sign in nonstop to use editor, and even when I do sign in. It wont let me use editor. It keeps saying that the product isnt registered. What do I do about this? I've registered, but it keeps happening...
    =============================================
    moved by moderator from Premiere Pro to Premiere Elements forum

    premiere elements 13 sos
    What computer operating system is your Premiere Elements 13 running on? Did you install from downloaded installation files or from an installation disc?
    Based on my prior experience, activation is the prime factor not registration, and it is automatic registration that comes along with a successful product activation. And, you need an Internet connection for product activation.
    Do you have a good Internet connection?
    Did you install the program with the antivirus and firewall(s) disabled?
    Are you getting a dialog box that says "License this product" or "Continue trial"?
    If you do, click on "License this product" on follow the instruction which will include entering your product's serial number at some point.
    Did you restart the computer after the product installation? Can you get into the Elements Organizer 13 to work there?
    Let us start here and then see if we can sort out the details that will lead to resolution of the problem.
    Thanks.
    ATR

  • Bind Variable in SELECT statement and get the value  in PL/SQL block

    Hi All,
    I would like  pass bind variable in SELECT statement and get the value of the column in Dynamic SQL
    Please seee below
    I want to get the below value
    Expected result:
    select  distinct empno ,pr.dept   from emp pr, dept ps where   ps.dept like '%IT'  and pr.empno =100
    100, HR
    select  distinct ename ,pr.dept   from emp pr, dept ps where   ps.dept like '%IT'  and pr.empno =100
    TEST, HR
    select  distinct loc ,pr.dept   from emp pr, dept ps where   ps.dept like '%IT'  and pr.empno =100
    NYC, HR
    Using the below block I am getting column names only not the value of the column. I need to pass that value(TEST,NYC..) into l_col_val variable
    Please suggest
    ----- TABLE LIST
    CREATE TABLE EMP(
    EMPNO NUMBER,
    ENAME VARCHAR2(255),
    DEPT VARCHAR2(255),
    LOC    VARCHAR2(255)
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (100,'TEST','HR','NYC');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (200,'TEST1','IT','NYC');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (300,'TEST2','MR','NYC');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (400,'TEST3','HR','DTR');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (500,'TEST4','HR','DAL');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (600,'TEST5','IT','ATL');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (700,'TEST6','IT','BOS');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (800,'TEST7','HR','NYC');
    COMMIT;
    CREATE TABLE COLUMNAMES(
    COLUMNAME VARCHAR2(255)
    INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('EMPNO');
    INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('ENAME');
    INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('DEPT');
    INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('LOC');
    COMMIT;
    CREATE TABLE DEPT(
    DEPT VARCHAR2(255),
    DNAME VARCHAR2(255)
    INSERT INTO DEPT(DEPT,DNAME) VALUES ('IT','INFORMATION TECH');
    INSERT INTO DEPT(DEPT,DNAME) VALUES ('HR','HUMAN RESOURCE');
    INSERT INTO DEPT(DEPT,DNAME) VALUES ('MR','MARKETING');
    INSERT INTO DEPT(DEPT,DNAME) VALUES ('IT','INFORMATION TECH');
    COMMIT;
    PL/SQL BLOCK
    DECLARE
      TYPE EMPCurTyp  IS REF CURSOR;
      v_EMP_cursor    EMPCurTyp;
      l_col_val           EMP.ENAME%type;
      l_ENAME_val       EMP.ENAME%type;
    l_col_ddl varchar2(4000);
    l_col_name varchar2(60);
    l_tab_name varchar2(60);
    l_empno number ;
    b_l_col_name VARCHAR2(255);
    b_l_empno NUMBER;
    begin
    for rec00 in (
    select EMPNO aa from  EMP
    loop
    l_empno := rec00.aa;
    for rec in (select COLUMNAME as column_name  from  columnames
    loop
    l_col_name := rec.column_name;
    begin
      l_col_val :=null;
       l_col_ddl := 'select  distinct :b_l_col_name ,pr.dept ' ||'  from emp pr, dept ps where   ps.dept like ''%IT'' '||' and pr.empno =:b_l_empno';
       dbms_output.put_line('DDL ...'||l_col_ddl);
       OPEN v_EMP_cursor FOR l_col_ddl USING l_col_name, l_empno;
    LOOP
        l_col_val :=null;
        FETCH v_EMP_cursor INTO l_col_val,l_ename_val;
        EXIT WHEN v_EMP_cursor%NOTFOUND;
          dbms_output.put_line('l_col_name='||l_col_name ||'  empno ='||l_empno);
       END LOOP;
    CLOSE v_EMP_cursor;
    END;
    END LOOP;
    END LOOP;
    END;

    user1758353 wrote:
    Thanks Billy, Would you be able to suggest any other faster method to load the data into table. Thanks,
    As Mark responded - it all depends on the actual data to load, structure and source/origin. On my busiest database, I am loading on average 30,000 rows every second from data in external files.
    However, the data structures are just that - structured. Logical.
    Having a data structure with 100's of fields (columns in a SQL table), raise all kinds of questions about how sane that structure is, and what impact it will have on a physical data model implementation.
    There is a gross misunderstanding by many when it comes to performance and scalability. The prime factor that determines performance is not how well you code, what tools/language you use, the h/w your c ode runs on, or anything like that. The prime factor that determines perform is the design of the data model - as it determines the complexity/ease to use the data model, and the amount of I/O (the slowest of all db operations) needed to effectively use the data model.

Maybe you are looking for

  • Can assign some Enhancement Framework to the same client????

    Hello experts, I would like to know that it is possible have some Enhancement Set Framework to the same client. In transaction sm30 with table "BSPWDV_EHSET_ASG" .I would like to assig different Enhancement Set to the same Client. It is possible?? I

  • Oracle Reports Version for R12.1.2?

    What version of Oracle Reports was used to develop rdfs for EBusiness Suite 12.1.2?

  • Screen macbook pro 2011 - error

    I noticed when writing a mail today and the PDF invoice me flashing cursor - the slow and fast movements. Not sure what to can - you have a problem with that and you? The display has been claimed (burned pixel) and then made ​​it even now - so the di

  • Javascript Error for Dropdown: oAccessibilityHelper is Undefined

    I have developer a WebDynpro (ABAP) component that has a DropdownByKey. The component is embedded in two different compoents that are part of different WD aplications. In application A, everything works fine, but in application B, I am getting a Java

  • How to remove icloud email from my ipad

    I had Update IOS 6.0.2 to 7.1.2 after Ipad restart I had wrong key the Setting and passby next question. After that Icoud setting appear wrong email address no match with my Apple ID, Please help to settle it...