All pastes #1346558 Raw Edit

Euler 5

public java v1 · immutable
#1346558 ·published 2009-02-25 05:51 UTC
rendered paste body
public class euler5 {	public static void main(String[] args){		int smallest = findSmallestDivisibleByAllBeneath(20); // Change "20" to desired number		System.out.println(smallest);	}	public static int findSmallestDivisibleByAllBeneath(int beneathNum) {		for(int testNum = beneathNum; testNum < Integer.MAX_VALUE; testNum += beneathNum) {			if(divisible(testNum, beneathNum))				return testNum;				}		return -50; // arbitrary failure value	}	public static boolean divisible(int testNum, int beneathNum){		for(int j = beneathNum; j > beneathNum/2; j--) 			if(testNum % j != 0)				return false;		return true;	}}