public static void main(String [] args) {

		int bestK = 0;
		int bestJ = 0;
		boolean solutionFound = false;
		boolean noSmallerSolutionExists = false;
		long smallestDifference = Long.MAX_VALUE;

		for (int k=1; !solutionFound && !noSmallerSolutionExists; k++) {
			long pk = penta(k);
			for (int j=1; j<k; j++) {
				long pj = penta(j);
				if (isPenta(pk-pj) && isPenta(pk+pj)) {
					if (!solutionFound) {
						// first solution found!
						solutionFound = true;
						bestK = k;
						bestJ = j;
						smallestDifference = pk-pj;
					} else {
						if (pk-pj < smallestDifference) {
							bestK = k;
							bestJ = j;
							smallestDifference = pk-pj;
						}
					}
				}
				// last time through k-loop, see if we have found the smallest possible solution
				if (j==k-1) {
					if (smallestDifference < 3*k-1) noSmallerSolutionExists = true;
				}
			}
		}
		System.out.println("k: " + bestK + ", j: " + bestJ + ", P(k): " + penta(bestK) + ", P(j): " + penta(bestJ));
		System.out.println(smallestDifference);
	}