Package clothcat.ssta.lib

Examples of clothcat.ssta.lib.Primes


        return true;
    }

    private int solve() {
        int sum = 0;
        List<Long> p = new Primes(1000000).getPrimeList();
        primes = new TreeSet<Long>();
        // only need primes with all digits 1,3,7 or 9
        for (long l : p) {
            primes.add(l);
        }
View Full Code Here


    }

    private int solve() {
        // start counting at 2 because we filtered out 2 and 5 which are valid examples
        int count = 2;
        TreeSet<Long> primes = new TreeSet<Long>(new Primes(1000000).getPrimeList());
        TreeSet<Long> filtered = new TreeSet<Long>();
        // remove impossible primes
        for (long l : primes) {
            if (!filter(l)) {
                filtered.add(l);
View Full Code Here

        System.out.println(new P50().solve());
    }

    private long solve() {
        final int MAX = 1000000;
        List<Long> p = new Primes(MAX).getPrimeList();
        TreeSet<Long> p1 = new TreeSet<Long>();
        for(Long l : p){
            p1.add(l);
        }
        long maxsum = 0;
View Full Code Here

        System.out.println(new P47().solve());
    }

    private int solve() {
        final int BOUND = 150000;
        Primes p = new Primes(BOUND);
        for (int i = 3; i < BOUND; i++) {
            if (p.getDistinctPrimeFactors(i).size() == 4
                    && p.getDistinctPrimeFactors(i + 1).size() == 4
                    && p.getDistinctPrimeFactors(i + 2).size() == 4
                    && p.getDistinctPrimeFactors(i + 3).size() == 4) {
                return i;
            }
        }

        // fallthrough -- won't get here unless BOUND is too small
View Full Code Here

    public static void main(String[] args) {
        System.out.println(new P10().solve());
    }

    private long solve() {
        ArrayList<Long> primes = new Primes(2000000).getPrimeList();
        long sum = 0;
        for (Long l : primes) {
            sum += l;
        }
        return sum;
View Full Code Here

    public static void main(String[] args) {
        System.out.println(new P7().solve());
    }

    private long solve() {
        ArrayList<Long> list = new Primes(1000000).getPrimeList();
        return list.get(10000);
    }
View Full Code Here

    public static void main(String[] args) {
        System.out.println(new P41().solve());
    }

    private long solve() {
        Primes primes = new Primes(123456789);
        ArrayList<Long> primeList = primes.getPrimeList();
        for (int i = primeList.size() - 1; i >= 0; i--) {
            if (StringUtils.isPandigital(String.valueOf(primeList.get(i)))) {
                return primeList.get(i);
            }
        }
View Full Code Here

        System.out.println(new P49().solve());
    }

    private String solve() {
        String answer = "";
        ArrayList<Long> primeList = new Primes(9999).getPrimeList();
        HashMap<String, Set<Long>> perms = new HashMap<String, Set<Long>>();

        // find permutational primes...
        for (long l : primeList) {
            if (l > 999) {
View Full Code Here

    }

    private long solve() {
        long n = 1;
        long t = 0;
        Primes p = new Primes(99999999);
       
        while(true){
            t=t+n;
            n++;
            System.out.println("Trying t: "+t);
            if(p.countDivisors(t)>500){
                return t;
            }
        }
    }
View Full Code Here

    public static void main(String[] args) {
        System.out.println(new P46().solve());
    }

    private int solve() {
        TreeSet<Long> primes = new TreeSet<Long>(new Primes(10000).getPrimeList());

        // guess at upperbound and tweak later...
        final int BOUND = 10000;
        for (int i = 3; i < BOUND; i += 2) {
            int j = 0;
View Full Code Here

TOP

Related Classes of clothcat.ssta.lib.Primes

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.