1. Member
Join Date
Feb 2013
Posts
1
Rep Power
0

I am not a programmer. I am a math student doing my senior thesis on prime numbers. Something I would like to do is run a mersenne prime number program and see how long it will take before my computer dies to show the limitations of current technology. I found this script online. BTW, if you recognize who wrote this please leave a name so I can give credit during my speach. Also can I just compile it and run it or do I need to do anything else to it? Also does anyone have any suggestions for an easy compiler to use?

Will

import
java.math.BigInteger;
import java.util.Scanner;
public class MersennePrime {
public static void main(String args[]) {
Scanner limiter = new Scanner(System.in);
System.out.println("Enter the max number of Mersenne Primes you want to find-->");
int counter = limiter.nextInt();
BigInteger prime = BigInteger.valueOf(2);
BigInteger mprime = BigInteger.valueOf(1);
String columnmaker = "|";
while (counter>0) {
boolean primechecker =true;
BigInteger divisor = BigInteger.valueOf(2);
BigInteger x =prime;
BigInteger root = BigInteger.valueOf (0);
BigInteger y =BigInteger.valueOf(-1);
while (x.compareTo(BigInteger.valueOf (0))>=0) {
if (x.compareTo(BigInteger.valueOf(0))==0) {
x=BigInteger.valueOf(-1);
}
}
while (root.compareTo(divisor)>=1) {
BigInteger reminder = mprime.remainder(divisor);
if (reminder.compareTo( BigInteger.valueOf(0)) == 0) {
primechecker = false;
divisor =mprime;
}
}
}
if (primechecker) {
columnmaker =columnmaker + mprime + "| |";
counter-=1;
}
prime =prime.multiply(BigInteger.valueOf(2));
}
System.out.println(columnmaker);
}
}

3. Re: finish the code please

grjmmr, please go through the Forum Rules, particularly the third paragraph.

Also go through http://www.java-forums.org/forum-gui...w-members.html and BB Code List - Java Programming Forum - Learn Java Programming and edit your post accordingly.

db

4. Member
Join Date
Feb 2011
Posts
78
Rep Power
0

BTW, if you recognize who wrote this please leave a name so I can give credit during my speach
That's rich.

What do you think is wrong with the program?

5. Re: finish the code please

Originally Posted by grjmmr
BTW, if you recognize who wrote this please leave a name so I can give credit during my speach.
Why don't you just credit the blog from where you lifted it?

db

Posting Permissions

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