Page 1 of 2 12 LastLast
Results 1 to 20 of 27
  1. #1
    aaroncarpet's Avatar
    aaroncarpet is offline Senior Member
    Join Date
    Nov 2009
    Location
    California
    Posts
    147
    Rep Power
    0

    Default looking for java programmers interested in testing code

    i am using my own java program to find huge mersenne primes (for example 2^62,000,000 power - 1) with the lucas lehmer test ...if you have a spare pc and are interested in the .java file and want to help tweak it let me know I will thoughroly comment the code so you can modify it and test it with smaller verfiable mersenne primes.
    Last edited by aaroncarpet; 11-13-2009 at 02:58 PM. Reason: moderator suggestion

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  3. #3
    aaroncarpet's Avatar
    aaroncarpet is offline Senior Member
    Join Date
    Nov 2009
    Location
    California
    Posts
    147
    Rep Power
    0

    Default Learning the ways of the forum

    my understanding is that I need to post more on other peoples threads then? I didn't use "urgent"

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    No need to post your question in different thread. Just post it on this. Others will comment on that for you.

  5. #5
    collin389 is offline Senior Member
    Join Date
    Nov 2009
    Posts
    235
    Rep Power
    5

    Default

    i'll do it. Could you attach the .java to a post?

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by collin389 View Post
    i'll do it. Could you attach the .java to a post?
    What you mean, attach what?

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    You can attach a zip file to your post and (I think) a text file. I usually create a jar file and then change the extension from jar to zip and then attach that to my post.

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  9. #9
    collin389 is offline Senior Member
    Join Date
    Nov 2009
    Posts
    235
    Rep Power
    5

    Default

    I think he's planing to get that OPs code and do a test run. :D
    What's wrong with that? And why cant he just copy the contents of his .java to a .txt and then attach that?

  10. #10
    Supamagier is offline Senior Member
    Join Date
    Aug 2008
    Posts
    384
    Rep Power
    7

    Default

    why can´t you attach java files? it's a java forum (H)
    I die a little on the inside...
    Every time I get shot.

  11. #11
    aaroncarpet's Avatar
    aaroncarpet is offline Senior Member
    Join Date
    Nov 2009
    Location
    California
    Posts
    147
    Rep Power
    0

    Default

    Here is the code for you to test i am not holding rights to it because very few people will have the patience to let this program run as long as it needs to....
    I have it set up initially to start testing at a low number 2^7-1(mersenne) so you can see how it operates. every time you restart the programe delete the primedata.txt file it creates when you hit the system out data button while it is in the middle of the lucas lehmer test it gives the lucas value the iteration the number and the power so you can re enter that data and restart using the lucas2 method....dont worry about that though

  12. #12
    aaroncarpet's Avatar
    aaroncarpet is offline Senior Member
    Join Date
    Nov 2009
    Location
    California
    Posts
    147
    Rep Power
    0

    Default

    Java Code:
    import javax.swing.*;
    import javax.swing.AbstractButton;
    import java.awt.event.*;
    import java.awt.GridLayout;
    import java.math.BigInteger;
    import java.util.Date;
    import java.util.Calendar;
    import java.io.RandomAccessFile;
    import java.io.File;
    import java.io.FileWriter;
    
    import java.util.GregorianCalendar;
    
    
    public class aaron1 extends JFrame implements ActionListener {
    
         File Data;
         RandomAccessFile mersenne_data;
         public JFrame MW;
         JPanel mainpanel;
         JButton tony, destroy;
         JScrollPane DataPane;
         JTextArea TA;
         long power = 3;
         long i;
    
          long time_number1, time_number2, time_number3, time_number4;
          float AT, percent_increase;
          GregorianCalendar ttime;
         BigInteger lucas,checker,Result, TWO;
    	aaron1(){ TWO = new BigInteger("2");
    	          Data = new File("Prime_Data.txt");
    	         try{ mersenne_data = new RandomAccessFile ( Data, "rw");
    
    			} catch (Exception e){};
    
    
    
    		    }
    
    
    		   void find_power (long x)//this method builds the large number
    		     {
    
                     ttime = new GregorianCalendar();
    				 time_number1= ttime.getTimeInMillis();
    
    				 System.out.println(time_number1);
    				 power = x;
    				 Result = new BigInteger("2");
    
    		    for (long k = 1; k < x; k++)
    	            	{Result = Result.multiply(TWO);
    	            	if(k % 1000 == 0)
    
    	           {   ttime = new GregorianCalendar();
    				   time_number2 = ttime.getTimeInMillis();
    				   time_number3 = time_number2 - time_number1;
    
    
    
    				   AT = ((time_number3 * (x -k) ) / k )  * ((float)time_number3 / (float)time_number4)  ;
    				   TA.append("It is going to take approximately "
    				                          + (AT/100/60) +"hours"+'\n');
    
    				   TA.append(time_number3 +"millisecends per 1000 iterations\n");
    
    
             time_number4 = time_number3;
    
    				   TA.append("power is at " + k + " out of" + power + '\n');
    
                               ttime = new GregorianCalendar();
                           time_number1= ttime.getTimeInMillis();
    
    
    
    
    
    	            	}
    
    
    						}
    			checker = Result.subtract(BigInteger.ONE);
    		    TA.append("2 to the " + x + " - 1 = " + checker);
    		}
    
    
    
    
    
      boolean lucas_test2()//not using this currently
        { lucas = new BigInteger("4540097");
    
    
      
    
    
    
    
         BigInteger mersenne = new BigInteger("29");
          checker = mersenne;
          power = 553;
          Result = checker.add(BigInteger.ONE);
          long z = 553;
          for(i = 70; i<=z; i++)
    {lucas = lucas.pow(2).subtract(TWO).mod(checker) ;
      if(i % 250 == 0)
    {MW.repaint(); TA.append("test is at " + i + " out of " + z + '\n');}
    }
        if(lucas.compareTo(BigInteger.ZERO) == 0)
            { TA.setText(null);
    			//for(int zz =0; zz<5000; zz++)
    
    		try{	mersenne_data.writeChars("***** 2^"+z+"-1  is prime ***** \n");
    			TA.append("***** 2^"+z+"-1  is prime ***** \n") ;
    
    
           String number = new String("" + checker);
    
           TA.append("the number is " + number + '\r');
           mersenne_data.writeChars("the number is " + number + '\r');
            TA.append("and it has " + number.length() + " digits \r");
    mersenne_data.writeChars("and it has " + number.length() + " digits \r");} catch(Exception e){}
            return true;}
        else
           {TA.setText(null);
    		   TA.append(" 2^"+z+"-1  is composite.\r") ; return false;}
          }
    
    
    
    
    
    
      boolean lucas_test(BigInteger mersenne, long z)
      {
    		 lucas = new BigInteger("4") ;  //initialize
          for( i=3; i<=z; i++)
              {lucas = lucas.pow(2).subtract(TWO).mod(mersenne) ;
               //System.out.println(new String(""+ lucas +'\n'));
               //System.out.println(i + "  th iteraation \n");
               //System.out.println("" + checker + "\n is the number \n and the power is \n" + power + "\n");
    
               if(i % 250 == 0)
             // try{ System.in.read();} catch (Exception e){};
               {MW.repaint(); TA.append("test is at " + i + " out of " + z + '\n');}
    }
        if(lucas.compareTo(BigInteger.ZERO) == 0)
            { TA.setText(null);
    			//for(int zz =0; zz<5000; zz++)
    
    		try{	mersenne_data.writeChars("***** 2^"+z+"-1  is prime ***** \n");
    			TA.append("***** 2^"+z+"-1  is prime ***** \n") ;
    
    
           String number = new String("" + checker);
    
           TA.append("the number is " + number + '\r');
           mersenne_data.writeChars("the number is " + number + '\r');
            TA.append("and it has " + number.length() + " digits \r");
    mersenne_data.writeChars("and it has " + number.length() + " digits \r");} catch(Exception e){}
            return true;}
        else
           {TA.setText(null);
    		   TA.append(" 2^"+z+"-1  is composite.\r") ; return false;}
          }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
     void Test () {lucas_test(checker, power);}
    
     void get_next_biggy()
        {  power +=2;
           Result = Result.multiply(TWO);
           Result = Result.multiply(TWO);
           checker = Result.subtract(BigInteger.ONE);
           TA.append("2^ " + power + " - 1 = " + checker);
    
      }
    
    	void add_buttons()
    	    {mainpanel = new JPanel();
    	     tony = new JButton("System Out Data");
    	     tony.addActionListener(this);
    	    mainpanel.setLayout(new GridLayout(2,1));
    	     TA = new JTextArea(100,50);
    	     TA.setLineWrap(true);
    	     DataPane = new JScrollPane(TA);
    	// DataPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
    
    	     mainpanel.add(tony);
    	     mainpanel.add(DataPane);
    	     MW= new JFrame("Tony Test");
    	     MW.setLocation(300,300);
    	     MW.setSize(500,300);
    	     MW.getContentPane().add(mainpanel);
    	     MW.setVisible(true);
    }
    public void actionPerformed(ActionEvent e)
    
      {if(e.getSource()==tony)
         { System.out.println(new String(""+ lucas +'\n'));
               System.out.println(i + "  th iteraation \n");
               System.out.println("" + checker + "\n is the number \n and the power is \n" + power + "\n");
              try{ mersenne_data.writeChars(new String(""+ lucas +'\n'));
               mersenne_data.writeChars(i + "  th iteraation \n");
               mersenne_data.writeChars("" + checker + "\n is the number \n and the power is \n" + power + "\n");
    }catch (Exception ee){}
               }
    	   }
    
    	public static void main( String args[]) {
    
                 aaron1 test= new aaron1();
                 test.add_buttons();
                 test.find_power((long)7);//62641207);start with 7 to see how it works then pick a big odd number when you want to run it for 30 days
    
                // test.lucas_test2();
                 test.Test();
                 while (true)
                 {
                 test.get_next_biggy();
                 test.Test();
    		 }
    
    		}//System.out.println("hello");}
    
    	}

    just copy paste compile and run dont use javaw---you need the shell

    when you run this with bigger numbers use this command line: java -Xms10m -Xmx1024m aaron1
    Last edited by aaroncarpet; 11-15-2009 at 05:25 PM. Reason: important running instructions

  13. #13
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by collin389 View Post
    What's wrong with that? And why cant he just copy the contents of his .java to a .txt and then attach that?
    Nothing at all, you can test the code. It's not choice lol.

    Regarding file attachment. You can attach files from the addition options, and to see those options you cannot follow quick replay. Go to advance options.

  14. #14
    aaroncarpet's Avatar
    aaroncarpet is offline Senior Member
    Join Date
    Nov 2009
    Location
    California
    Posts
    147
    Rep Power
    0

    Default no one will run this because of runtime

    It takes months to verify primes of 40 million digits plus because you have to use big integer(not primitive type)....and if the computer restarts you are SOL but i created a method to capture mid testing data but i need to create another method to read it from a file because the string is too long at compile time...

  15. #15
    aaroncarpet's Avatar
    aaroncarpet is offline Senior Member
    Join Date
    Nov 2009
    Location
    California
    Posts
    147
    Rep Power
    0

    Default

    have I been blocked from posting code????????????

  16. #16
    aaroncarpet's Avatar
    aaroncarpet is offline Senior Member
    Join Date
    Nov 2009
    Location
    California
    Posts
    147
    Rep Power
    0

    Default

    i keep getting slider bars

  17. #17
    aaroncarpet's Avatar
    aaroncarpet is offline Senior Member
    Join Date
    Nov 2009
    Location
    California
    Posts
    147
    Rep Power
    0

    Default

    test.find_power((long)7);//62641207);start with 7 to see how it works then pick a big odd prime number when you want to run it for 30 days

  18. #18
    aaroncarpet's Avatar
    aaroncarpet is offline Senior Member
    Join Date
    Nov 2009
    Location
    California
    Posts
    147
    Rep Power
    0

    Default

    I am going to repost the code with thurough comments

  19. #19
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    aaroncarpet, please slow down your posting here. Without any major response at all you just post them. Try to post complete/clear question within few post. Seems to me you are just trying to your total number of posts in the forum.

  20. #20
    dinosoep is offline Senior Member
    Join Date
    Nov 2009
    Posts
    150
    Rep Power
    5

    Default

    do you know that they use thousands of computers for calculating this?
    why are you starting on your own?

Page 1 of 2 12 LastLast

Similar Threads

  1. Getting rid of commas in large numbers?
    By wwuster in forum Advanced Java
    Replies: 12
    Last Post: 03-05-2012, 10:35 AM
  2. Large data over RMI
    By JavaDesigner in forum New To Java
    Replies: 7
    Last Post: 10-16-2009, 08:48 PM
  3. Draw Large Images
    By Sreekanth.m in forum Java 2D
    Replies: 1
    Last Post: 09-08-2009, 04:53 PM
  4. Reading large XML
    By gkumar in forum XML
    Replies: 3
    Last Post: 08-06-2009, 04:38 AM
  5. printing two smallest numbers from a series of numbers
    By trofyscarz in forum New To Java
    Replies: 2
    Last Post: 10-14-2008, 11:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •