Skip to content

Instantly share code, notes, and snippets.

@aeg
Created January 3, 2013 18:39
Show Gist options
  • Save aeg/4445793 to your computer and use it in GitHub Desktop.
Save aeg/4445793 to your computer and use it in GitHub Desktop.
対数を計算する
// Case #1
// 自然対数を計算する
assert Math.log(72) ==4.276666119016055
assert Math.log(Math.E) == 1
// Case #2
// 10を底とした対数を計算する
assert Math.log10(1000) == 3.0
// Case #3
// 任意の底の対数を計算する
def logn(n, val) { Math.log(val) / Math.log(n) }
assert logn(2, 1024) == 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment