<file_sep>public class project1 {

    public static void main(String[] args) {
        int y;
        //int x = 1000;
        y = multAdd(100);
        System.out.println("sum " + y);

        y = multAdd(1000);
        System.out.println("500 sum " + y);
    }

    public static int multAdd(int x){
        int sum = 0;
        for (int i=0; i < x; i++) {
            if( ((i % 3)==0) || ((i % 5)==0) ){
                sum += i;
            }
        }
        return sum;
    }
}
<file_sep>public class binaryGap {


    public static void main(String[] args ){

        System.out.println("20 expected 1   " + solution(20));
        System.out.println("34 expected 3   " + solution(34));
        System.out.println("8 expected 0 " + solution(8));
        System.out.println("328 expected 2    " + solution(328));
        System.out.println("1041 expected 5   " + solution(1041));
        System.out.println("51712 expected 2 " + solution(51712));
    }

    public static int solution(int N){
        int count=0;
        int largestCount=0;
        boolean trailing = true;

        while(N != 0){
            if(N % 2 == 1){
                //it's an odd number
                trailing = false;
                largestCount = count > largestCount ? count : largestCount;
                count = 0;
            }
            else {
                //Even number, the binary is 0
                count = trailing ? 0 : count + 1 ;
            }
            N = N / 2;
        }

        //check if the count is greater than 0.
        return largestCount;
    }





}
<file_sep># ProjectEuler

This is a project to improve and hone my programming skills for Java.

<file_sep>public class smallestMultiple {

    //Problem 5 SmallestMultiple
    // 2520 is the smallest number that can de divied by each of the number from 1 to 10 without any remainder
    // what is the smallest positive number that is evenly divisibly by all of the numbers from 1 to 20?


    public static void main (String[] args){

        System.out.println("N=3 and excepted 6 ==" +  smallestMultiple(3) );
        System.out.println("N=4 and excepted 12 ==" +  smallestMultiple(4) );
        System.out.println("N=5 and excepted 60=" +  smallestMultiple(5) );
        System.out.println("N=10 and excepted 2520=" +  smallestMultiple(10) );
        //System.out.println("N=20 and excepted 2520=" +  smallestMultiple(20) );
    }



    public static int smallestMultiple(int n){
        int smallest = 0;
        boolean found= false;

        while(!found){
            smallest++;
            for (int i = 1; i <= n; i++) {
                if (smallest % i != 0){
                    break ;
                }
                if( smallest % i == 0 && i == n){
                    found=true;
                }
            }
        }
        return smallest;
    }


    //////////////////////////////////////////////////////
    //would work in c++
//    public static int smallestMultiple(int n) {
//        int smallest = 0;
//        boolean found = false;
//
//        while (!found) {
//            found = isValid(smallest, n);
//        }
//        return smallest;
//    }
//
//    public static boolean isValid(int smallest, int n){
//
//        for (int i = 1; i <= n; i++) {
//            if (smallest % i != 0){
//                return false;
//                //move on to the next one
//            }
//            if( smallest % i == 0 && i == n){
//                return true;
//            }
//        }
//        return false;
//    }
}
