Project Euler – Problem 35

Problem 35: How many circular primes are there below one million?

import java.util.Vector;
 
class runner
{
	private static boolean isPrime(int n){
		//if(primes.contains(n)) return true; Unnecessary for the code written.
		double sqrt = Math.sqrt(n);
		for(int i=0;i sqrt) break;
			if(n % primes.get(i) == 0) return false;
		}
		primes.add(n);
		return true;
	}
 
	private static boolean isCyclicalPrime(int n){ 
		double len = Math.floor( Math.log10( n != 0 ? n : 1 ) ) + 1;
 
		//197 -> 971 -> 719
		for(int i=1;i primes = new Vector();
	public static void main (String[] args) throws java.lang.Exception
	{
		long time = System.currentTimeMillis();
 
		for(int i=2;i<1000000;i++){
			isPrime(i);
		}
		System.out.println("time: "+(System.currentTimeMillis() - time));
		
		int count = 0;
		for(int i=0;i


Note: isCyclicalPrime takes a little over 62sec on my machine.. not good.
Edit: Issue was the fact I was using a Vector..., the following takes 99ms

 
class runner
{
	private static void primeSieve(boolean[] primes){
		for(int i=2;i= primes.length) break;
				primes[prod] = false;
			}
		}
	}
 
	private static boolean isCyclicalPrime(int n, boolean[] primes){ 
		double len = Math.floor( Math.log10( n != 0 ? n : 1 ) ) + 1;
 
		//197 -> 971 -> 719
		for(int i=1;i