Skip to content

Instantly share code, notes, and snippets.

@eriktaubeneck
Created April 2, 2020 16:22
Show Gist options
  • Save eriktaubeneck/42b426fb05a23d9224673a02c046bebd to your computer and use it in GitHub Desktop.
Save eriktaubeneck/42b426fb05a23d9224673a02c046bebd to your computer and use it in GitHub Desktop.
function not_inc(x)
Float64(x) == Float64(x+1)
end
function perc_inc(e, n)
s = 0
for i in 0:n
s += Int(not_inc(2^e + i))
end
1-s/n
end
# julia> perc_inc(53, 2^20)
# 0.4999990463256836
# julia> perc_inc(54, 2^20)
# 0.2499990463256836
# julia> perc_inc(55, 2^20)
# 0.1249990463256836
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment