Java code for project euler