9 static ArrayList<Integer> primes =
10 new ArrayList<Integer>();
11
12 void SieveOfEratosthenes()13 {14 // Create a boolean array "IsPrime[0..MAX_SIZE]"15 // and initialize all entries it as true.16 // A value in IsPrime[i] will finally be false17 // if i is Not a IsPrime, else true.18 boolean [] IsPrime = new boolean[MAX_SIZE];19 20 for(int i = 0; i < MAX_SIZE; i++)21 IsPrime[i] = true;22 23 for (int p = 2; p * p < MAX_SIZE; p++)24 {25 // If IsPrime[p] is not changed,26 // then it is a prime27 if (IsPrime[p] == true)28 {29 // Update all multiples of p greater than or30 // equal to the square of it31 // numbers which are multiple of p and are32 // less than p^2 are already been marked.33 for (int i = p * p; i < MAX_SIZE; i += p)34 IsPrime[i] = false;35 }36 }37 38 // Store all prime numbers39 for (int p = 2; p < MAX_SIZE; p++)40 if (IsPrime[p] == true)41 primes.add(p);42 }43 public int run() {
44 SieveOfEratosthenes();
45 return primes.get(10000);
44 SieveOfEratosthenes();
45 return primes.get(10000);
46 }
47 public static void main (String[] args) {48 System.out.println(new p007().run());49 }50}
40 if (IsPrime[p] == true)
41 primes.add(p);
42 }
43 public int run() {44 SieveOfEratosthenes();45 return primes.get(10000);46 }47 public static void main (String[] args) {
48 System.out.println(new p007().run());
49 }
1package javasec;
2
3public class p006 {
4 public double run() { 5 int total = 0; 6 int total2 = 0; 7 for (int i = 1; i <= 100; i++) { 8 total += Math.pow(i, 2); 9 total2 += i;10 };11 return (Math.pow(total2, 2) - total);12 }13 public static void main(String[] args) {
14 System.out.println(new p006().run());
15 }
10 };
11 return (Math.pow(total2, 2) - total);
12 }
13 public static void main(String[] args) {14 System.out.println(new p006().run());15 }16}
This method does not have any documentation.
Consider adding a documentation comment to explain its use.
While it may seem like the usage of a method is perfectly obvious, any consumers of your API may not be able to pick up on certain details.
This method appears to return an address string based on its name and the return type, but it is hard to say anything further about it. We neither know if the address will be formatted in a special way nor are we given any useful information regarding the returned value.
String getAddress() {
// ...
}
Provide a detailed description of what the method does.
/**
* Returns the address in 3 line format,
* with street address on line 1, area/city on line 2
* and state and country as well as postal code on line 3.
*/
String getAddress() {
// ...
}