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
Solution Project Euler Problem 12 Java
January 6th, 2009Solution Project Euler Problem 10 Java
December 28th, 2008I 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
Solution Problem 9 Project Euler
December 22nd, 2008Solution Problem 8 Project Euler
December 21st, 2008Solution Problem 7 Project Euler
December 10th, 2008Solution Problem 6 Project Euler
December 8th, 2008I 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
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.
Solution Problem 5 Project Euler
December 5th, 2008I 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
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.
Solution Problem 4 Project Euler
November 25th, 2008I 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
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.
Solution to Problem 3 Project Euler
November 6th, 2008I 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
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.
Solution to Project Euler Problem 2 Using Java
October 19th, 2008I have solved problem 2 of 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 2 is here
What I used for solving the problem was a procedural implementation of the fibonacci series. If you program in java you always have to remember that primitives are faster than Number objects. BTW the solutions is a brute force approach, but it runs pretty fast in Java.