Skip to content

Instantly share code, notes, and snippets.

@mb6ockatf
Created February 11, 2024 19:01
Show Gist options
  • Save mb6ockatf/059d9cfc43a3fa2ad22c846a0526b8cc to your computer and use it in GitHub Desktop.
Save mb6ockatf/059d9cfc43a3fa2ad22c846a0526b8cc to your computer and use it in GitHub Desktop.
#!/usr/bin/julia
const eps = 1e-40;
function log_2(n::Int64)
x = 1;
previous = 0;
while abs(2 ^ x - n) > eps
println(x);
x = (x + n / x) / 2;
if x != previous
previous = x;
else
break;
end
end
return x;
end
println(log_2(256));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment