import java.io.*; import java.util.*; /** * Solution to Flooring Tiles * * @author vanb */ public class flooringtiles { public Scanner sc; public PrintStream ps; // The largest possible value, // as stated in the problem public static final long biggest = 1000000000000000L; // We'll precompute prime powers to speed things up. // primepowers[i][j] will be i^j, if i is prime and i^j biggest ) { primepowers[i][j] = 0L; break; } } } for(;;) { int n = sc.nextInt(); if( n==0 ) break; // If you can form n unique rectangles with x little boxes, then there // must be n factors of x less than or equal to its square root. So, there are // two cases - either it has 2n total factors, or it's a perfect square // and it has 2n-1 factors. We'll compute both, and take the smaller of the two. long answer = Math.min( minimum( n+n, 2, false, n+n ), minimum( n+n-1, 2, true, n+n ) ); ps.println( answer ); } } public static void main( String[] args ) throws Exception { new flooringtiles().doit(); } }