Skip to content

Instantly share code, notes, and snippets.

@thmain
Created June 7, 2018 04:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thmain/80c9fa81ea7ce63c07d2fa468d0d0413 to your computer and use it in GitHub Desktop.
Save thmain/80c9fa81ea7ce63c07d2fa468d0d0413 to your computer and use it in GitHub Desktop.
public class Logn {
static void computeLogN(int n){
int result = 0;
int number = n;
while(n>0){
n=n/2;
if(n>=1)
result++;
}
System.out.println("Log"+number + " value: " + result);
}
public static void main(String[] args) {
int n = 64;
computeLogN(n);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment