int main(void){ int k, n; scanf("%d", &k); while(k>0){ scanf("%d", &n); printf("%d\n", piso_log2(n)); k--; } return 0; }
int main (int argc, char *argv[]) { int ctrl, i, x = 1, b = atoi (argv[1]), k = atoi (argv[2]); for (i = 1; i <= k; i++) { ctrl = pot (b, i, &x); if (ctrl == STATUS_FAIL) { printf ("Overflow aritmetico\n"); return 0; } printf ("%10d | %10d \n", x, piso_log2 (x)); } return 0; }
void pisolog (int b, int k) { int x, i = 0; printf (" k | Piso (log (2) %d ^ k)\n", b); while (1) { if (i == k) break; x = piso_log2 (b, i+1); if (x == OVF) { printf ("Overflow aritmetico.\n"); return; } printf ("%10d | %10d\n", i + 1, x); i++; } return; }
int piso_log2(int n){ if(n==1) return 0; return piso_log2(n/2)+1; }