Skip to content

Instantly share code, notes, and snippets.

@swshan
Created March 6, 2017 09:38
Show Gist options
  • Save swshan/d322e4389cda4edac081be147bac2ef1 to your computer and use it in GitHub Desktop.
Save swshan/d322e4389cda4edac081be147bac2ef1 to your computer and use it in GitHub Desktop.
算法4书本练习 1.1.14
import java.util.*;
// 给一个N的正帧数 返回不大于Log2N的最大整数
public class Log {
public static int lg(int N) {
double log2n = N / 2; // base is 2
int result = 1;
while ( result < log2n) {
result++;
}
return result;
}
public static void main(String[] args) {
int number = Log.lg(10);
System.out.println(number);
}
}
Copy link

ghost commented Sep 28, 2017

你这结果错了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment