odie5533
11-25-2004, 04:31 AM
I need to make a program in java which inputs a number, and finds the prime number AFTER it. It has to do it as quick as possible, and use the long start = System.currentTimeMillis(); to do the timing. I have no idea where to start, tried a few things, none of which will work. Any ideas/help?
Brandoe85
11-25-2004, 04:51 AM
This homework? try posting what you've done and someone can point you in the right direction...
odie5533
11-25-2004, 04:57 AM
Not homework, extra practice. I have no idea where to begin. I can kinda check if a number is prime, but it'll take too long once it gets high numbers, checkng every number...
Brandoe85
11-25-2004, 05:53 AM
I once made a program when I was learning java that would accept a number from the user, and then print all the prime numbers after it, I'm not sure if it'd be of any help to you...let me know, otherwise i'm sure some of the java guys can surely help you out :D
odie5533
11-25-2004, 05:56 AM
Anything would help at this point...
I now have a prob though, how do I store 90,000,000,000,000,000 into a number...
Antoniohawk
11-25-2004, 04:18 PM
Here's what you'll need for that huge number. [http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigInteger.html]
odie5533
11-25-2004, 06:43 PM
I can't understand how BigInteger works, can you show me an example, of like the BigInteger being multiplied by 3?
Antoniohawk
11-25-2004, 11:05 PM
I'm pretty sure that you just replace "int" with BigInteger as follows.
BigInteger bigNumber = 1,000,000,000;