Created
January 3, 2013 18:39
-
-
Save aeg/4445793 to your computer and use it in GitHub Desktop.
対数を計算する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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