Java tutorial
//package com.java2s; public class Main { public static double calculateMinZoomLevel(int width, int height, int tileSize) { int max = Math.max(width, height); int tilesCount = (int) Math.ceil(1d * max / tileSize); return Math.ceil(Math.log(tilesCount) / Math.log(2d)); } }