File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
OOP in Java/Chapter 10 - Object-Oriented Thinking/Code_Example Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ package ch_10 ;
2+
3+ import java .math .BigInteger ;
4+ import java .util .Arrays ;
5+
6+ /**
7+ * 10.18 (Large prime numbers) Write a program that finds five prime numbers larger
8+ * than Long.MAX_VALUE.
9+ */
10+ public class Exercise10_18 {
11+ // BigInteger TWO = BigInteger.valueOf(2L);
12+ static final BigInteger lowerBound = BigInteger .valueOf (Long .MAX_VALUE );
13+ BigInteger [] primeBigIntegers = new BigInteger [5 ];
14+ BigInteger testNum = lowerBound ;
15+
16+ public static void main (String [] args ) {
17+ Exercise10_18 obj = new Exercise10_18 ();
18+
19+ int idx = 0 ;
20+ while (idx < 5 ) {
21+ obj .testNum = obj .testNum .nextProbablePrime ();
22+ obj .primeBigIntegers [idx ] = obj .testNum ;
23+ idx ++;
24+ }
25+ System .out .println (Arrays .toString (obj .primeBigIntegers ));
26+ }
27+
28+ }
You can’t perform that action at this time.
0 commit comments