import java.util.Scanner; public class Demo4 { public static void main(String[] argv) { Scanner in = new Scanner(System.in); System.out.print("Enter n = "); int n = in.nextInt(); int c = 0; int sum = 0; for ( int i = 1; i <= n; i = 2*i ) { sum = sum + 1; c++ ; // Count # times we exec the loop } System.out.println("# time loop executed = " + c); System.out.println("log(n) = " + Math.log(n)/Math.log(2)); } }