Results 1 to 20 of 27
Thread: crunching large numbers
 11132009, 08:24 AM #1
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; 11132009 at 03:58 PM. Reason: moderator suggestion
 11132009, 11:27 AM #2
 Join Date
 Jul 2007
 Location
 Colombo, Sri Lanka
 Posts
 11,370
 Blog Entries
 1
 Rep Power
 23
You want to find someone to test your code?
 11132009, 03:53 PM #3
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"
 11132009, 03:56 PM #4
 Join Date
 Jul 2007
 Location
 Colombo, Sri Lanka
 Posts
 11,370
 Blog Entries
 1
 Rep Power
 23
No need to post your question in different thread. Just post it on this. Others will comment on that for you.
 11152009, 06:54 AM #5Senior Member
 Join Date
 Nov 2009
 Posts
 236
 Rep Power
 9
i'll do it. Could you attach the .java to a post?
 11152009, 07:22 AM #6
 Join Date
 Jul 2007
 Location
 Colombo, Sri Lanka
 Posts
 11,370
 Blog Entries
 1
 Rep Power
 23

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.
 11152009, 07:38 AM #8
 Join Date
 Jul 2007
 Location
 Colombo, Sri Lanka
 Posts
 11,370
 Blog Entries
 1
 Rep Power
 23
I think he's planing to get that OPs code and do a test run. :D
 11152009, 09:23 AM #9Senior Member
 Join Date
 Nov 2009
 Posts
 236
 Rep Power
 9
I think he's planing to get that OPs code and do a test run. :D
 11152009, 02:54 PM #10Senior Member
 Join Date
 Aug 2008
 Posts
 384
 Rep Power
 10
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.
 11152009, 05:24 PM #11
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^71(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
 11152009, 05:27 PM #12Java 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 javawyou need the shell
when you run this with bigger numbers use this command line: java Xms10m Xmx1024m aaron1Last edited by aaroncarpet; 11152009 at 06:25 PM. Reason: important running instructions
 11162009, 04:05 AM #13
 Join Date
 Jul 2007
 Location
 Colombo, Sri Lanka
 Posts
 11,370
 Blog Entries
 1
 Rep Power
 23
 11162009, 06:52 AM #14
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...
 11162009, 05:51 PM #15
have I been blocked from posting code????????????
 11162009, 05:52 PM #16
i keep getting slider bars
 11162009, 05:53 PM #17
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
 11162009, 06:11 PM #18
I am going to repost the code with thurough comments
 11192009, 05:46 PM #19
 Join Date
 Jul 2007
 Location
 Colombo, Sri Lanka
 Posts
 11,370
 Blog Entries
 1
 Rep Power
 23
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.
 11192009, 07:09 PM #20Senior Member
 Join Date
 Nov 2009
 Posts
 150
 Rep Power
 9
Similar Threads

Getting rid of commas in large numbers?
By wwuster in forum Advanced JavaReplies: 12Last Post: 03052012, 11:35 AM 
Large data over RMI
By JavaDesigner in forum New To JavaReplies: 7Last Post: 10162009, 09:48 PM 
Draw Large Images
By Sreekanth.m in forum Java 2DReplies: 1Last Post: 09082009, 05:53 PM 
Reading large XML
By gkumar in forum XMLReplies: 3Last Post: 08062009, 05:38 AM 
printing two smallest numbers from a series of numbers
By trofyscarz in forum New To JavaReplies: 2Last Post: 10152008, 12:46 AM
Bookmarks