int index = FindIndexOf(arr, target);
Console.WriteLine(index);
Console.WriteLine(arr[index] == target);
public static void Main()
Test[] tests = new Test[]{
arr = new int[]{2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1},
arr = new int[]{80, 40, 20, 10, 5},
foreach (var test in tests)
public static int FindIndexOf(int[] array, int value)
return (int)Math.Log(array[0] / value, 2);