Category Archives: Uncategorized
Solution Project Euler Problem 13 Java
I have solved problem 13 of Project Euler. I created a google code hosted project here where you can check out the solutions to the problems I have solved. In particular the solution to problem 13 is here
Problem013.java Continue reading
Solution Project Euler Problem 12 Java
I have solved problem 12 of Project Euler. I created a google code hosted project here where you can check out the solutions to the problems I have solved. In particular the solution to problem 12 is here
Problem012.java Continue reading
Solution Project Euler Problem 10 Java
I have solved problem 10 of Project Euler. I created a google code hosted project here where you can check out the solutions to the problems I have solved. In particular the solution to problem 10 is here
Problem010_SieveOfErastothenes.java Continue reading
Solution Problem 9 Project Euler
I have solved problem 9 of Project Euler. I created a google code hosted project here where you can check out the solutions to the problems I have solved. In particular the solution to problem 9 is here
Problem009.java Continue reading
Solution Problem 8 Project Euler
I have solved problem 8 of Project Euler. I created a google code hosted project here where you can check out the solutions to the problems I have solved. In particular the solution to problem 8 is here
Problem008.java Continue reading
Solution Problem 7 Project Euler
I have solved problem 7 of Project Euler. I created a google code hosted project here where you can check out the solutions to the problems I have solved. In particular the solution to problem 7 is here
Problem007.java Continue reading
Solution Problem 6 Project Euler
I have solved problem 6 of Project Euler. I created a google code hosted project here where you can check out the solutions to the problems I have solved. In particular the solution to problem 6 is here
Problem006.java
The solution only has the optimization of finding the sum of the nth number through the formula
sum(n) = n * ( n + 1) / 2
Hope the solution is understandable. If not, don’t hesitate to put a comment. Continue reading
Solution Problem 5 Project Euler
I have solved problem 5 of Project Euler. I created a google code hosted project here where you can check out the solutions to the problems I have solved. In particular the solution to problem 5 is here
Problem005.java
A brute force approach to solving this problem. The solution has a minor optimization which is to increase the outer loop by 20 (the “limit” variable) in each iteration.
Hope the solution is understandable. If not, don’t hesitate to put a comment. Continue reading
Solution Problem 4 Project Euler
I have solved problem 4 of Project Euler. I created a google code hosted project here where you can check out the solutions to the problems I have solved. In particular the solution to problem 4 is here
Problem004.java
The solution is a brute force approach. I initialize two numbers to 999 and then iterate down on each of them separately until we reach zero on both. At this point we should have the two three digit numbers that make up the largest palindrome.
Hope the solution is understandable. If not, don’t hesitate to put a comment. Continue reading
Solution to Problem 3 Project Euler
I have solved problem 3 of the Project Euler using java. I created a google code hosted project here where you can check out the solutions to the problems I have solved. In particular the solution to problem 3 is here
Problem003.java
Below I will try to describe the algorithm I used to solve the problem:
a) We will iterate starting at 3 to the number numberToGetLargestPrimeFactor / largestPrimeFactor . Where the numberToGetLargestPrimeFactor is initialized to 600851475143L and largestPrimeFactor is the largest prime number calculated up to that point in the iteraton, it is initialized at 1.
b) At each iteration we will check if the i divides numberToGetLargestPrimeFactor exactly.
c) If i divides numberToGetLargestPrimeFactor exactly then we will find out if i is a prime number.
d) To check if i is a prime number we do it by trying to divide i between the different numbers in the list of prime numbers. If it is divided by one of them then it means that i is not a prime number.
e) If i is a primer number then we store it in the list of primes. And we make largestPrimeFactor equal to the value of i.
Hope this helps in understanding the algorithm. Continue reading