GooseterV / Project-Euler

Type names must begin with an uppercase letter JAVA-C1001
Style
Major
a year agoa year old
Typename does not follow Java naming conventions
 1package javasec;
 2import java.util.ArrayList;
 3public class p007 4// from geeksforgeeks https://www.geeksforgeeks.org/program-to-find-the-nth-prime-number/ 5{ 6	static int MAX_SIZE = 1000005; 7	  8	 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);46	}47	public static void main (String[] args) {48		System.out.println(new p007().run());49	}50}
Typename does not follow Java naming conventions
 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	}16}
Typename does not follow Java naming conventions
 1package javasec;
 2
 3public class p005 { 4	public int gcd(int a, int b) { 5		while (b != 0) { 6			int c = a % b; 7			a = b; 8			b = c; 9		}10		return a;11	}12	public int lcm(int a, int b) {13		return a / gcd(a, b) * b;14	}1516	public int run() {17		int count = 1;18		for (int i = 1; i < 21; i++) {19			count *= (int)Math.floor(i / gcd(i, count));20		}21		return count;22	}23	public static void main(String[] args) {24		System.out.println(new p005().run());25	}26}
Typename does not follow Java naming conventions
 4import java.util.ArrayList;
 5import java.lang.String;
 6
 7public final class p004 { 8	static String reverse(String str) { 9		return new StringBuilder(str).reverse().toString();10	}11	public Boolean isPalendromic(Integer n) {12		return n.toString().equals(reverse(n.toString()));13	}14	public Integer compute() {15		ArrayList<Integer> palendromes = new ArrayList<Integer>();16		for (Integer i = 100; i < 1000; i++) {17			for (Integer j = 100; j < 1000; j++) {18				Integer k = i * j;19				if (isPalendromic(k)) {20					palendromes.add(k);21				}22				23			}24			25		}26		return Collections.max(palendromes);27	}28	public static void main(String[] args) {29		System.out.println(new p004().compute());30	}31}
Typename does not follow Java naming conventions
 1package javasec;
 2
 3public class p003 { 4	public long smallestFactor(long x) { 5		for (int i = 2; i <= Math.floor(Math.pow(x, 0.5f)); i++) { 6			if (x % i == 0) { 7				return i; 8			} 9		}10		return x;  11	}12	public long run() {13		long x = 600851475143L;14		while (true) {15			long y = smallestFactor(x);16			if (y < x)17				x /= y;18			else19				return x;20		}21	}22	public static void main(String[] args) {23		System.out.println(new p003().run());24	}25}