This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.List; | |
import java.util.Set; | |
import java.util.TreeSet; | |
class Scratch { | |
public static void main(String[] args) { | |
// int max = 10; // 23 | |
int max = 1000; // 233168 | |
int sum = findMultiplesV2(max); | |
System.out.println("Sum is: " + sum); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Set; | |
import java.util.TreeSet; | |
class Scratch { | |
public static void main(String[] args) { | |
long sum = findSolution(); | |
System.out.println(sum); | |
} | |
private static long findSolution() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashMap; | |
import java.util.Map; | |
class Scratch { | |
public static void main(String[] args) { | |
long number = 600851475143L; | |
// long number = 13195; | |
long result = findLargestPrimeFactor(number); | |
System.out.println(result); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.TreeSet; | |
class Scratch { | |
static StringBuilder sb = new StringBuilder(); | |
public static void main(String[] args) { | |
int solution = findLargestPalindrome(); | |
System.out.println(solution); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Scratch { | |
public static void main(String[] args) { | |
System.out.println(solution(10)); | |
} | |
private static int solution(int max) { | |
int sumOfSquares = 0, sum = 0; | |
for (int i = 1; i <= max; i++) { | |
sumOfSquares += (i * i); | |
sum += i; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.math.BigInteger; | |
import java.util.ArrayList; | |
import java.util.List; | |
class Scratch { | |
public static void main(String[] args) { | |
System.out.println(solution()); | |
} | |
private static int solution() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.math.BigInteger; | |
class Scratch { | |
private static String NUMBER = "73167176531330624919225119674426574742355349194934" + | |
"96983520312774506326239578318016984801869478851843" + | |
"85861560789112949495459501737958331952853208805511" + | |
"12540698747158523863050715693290963295227443043557" + | |
"66896648950445244523161731856403098711121722383113" + | |
"62229893423380308135336276614282806444486645238749" + | |
"30358907296290491560440772390713810515859307960866" + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Scratch { | |
public static void main(String[] args) { | |
Scratch s = new Scratch(); | |
Triplet t = s.solution(); | |
System.out.println("The triplet is: " + t.a + "," + t.b + "," + t.c); | |
int product = t.a * t.b * t.c; | |
} | |
private Triplet solution() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; | |
import java.util.stream.Collectors; | |
class Scratch { | |
static final boolean COMPOSITE = false; | |
static final boolean PRIME = true; | |
public static void main(String[] args) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Scratch { | |
static long CURRENT_MAX = Long.MIN_VALUE; | |
public static void main(String[] args) { | |
int[][] grid = setupGrid(); | |
computeMaxProduct(grid); | |
System.out.println(CURRENT_MAX); | |
} | |
private static void computeMaxProduct(int[][] grid) { |
OlderNewer