Given a how to find the maximum value of n , if 2^n <a
Sol :
Sol :
public class maxN {
public static void main(String[] args) {
System.out.println(log2n(20));
}
private static int log2n(int n) {
return (n > 1) ? 1 + log2n(n / 2) : 0;
}
}
public class maxN {
public static void main(String[] args) {
System.out.println(log2n(20));
}
private static int log2n(int n) {
return (n > 1) ? 1 + log2n(n / 2) : 0;
}
}
No comments:
Post a Comment