Java tutorial
//package com.java2s; //License from project: Apache License public class Main { private static int getClosestResampleSize(int cx, int cy, int maxDim) { int max = Math.max(cx, cy); int resample = 1; for (resample = 1; resample < Integer.MAX_VALUE; resample++) { if (resample * maxDim > max) { resample--; break; } } if (resample > 0) { return resample; } return 1; } }