GooseterV / Project-Euler

Undocumented method found JAVA-D1001
Documentation
Minor
a year agoa year old
Consider adding a doc comment for SieveOfEratosthenes
 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);
Consider adding a doc comment for main
44		SieveOfEratosthenes();
45		return primes.get(10000);
46	}
47	public static void main (String[] args) {48		System.out.println(new p007().run());49	}50}
Consider adding a doc comment for run
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	}
Consider adding a doc comment for run
 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	}
Consider adding a doc comment for main
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}