-
-
Save ngsw-taro/4239085 to your computer and use it in GitHub Desktop.
宿題
This file contains 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
fun divisor(val a: Int,val b: Int) : Int = if(b == 0) a else divisor(b, a % b) | |
fun main(args: Array<String>){ | |
test(1, divisor(1, 1)) | |
test(2, divisor(2, 4)) | |
test(2, divisor(4, 2)) | |
test(6, divisor(24, 18)) | |
test(6, divisor(18, 24)) | |
test(1, divisor(13, 19)) | |
test(1, divisor(19, 13)) | |
} | |
fun test(expected : Int, actual : Int) { | |
if(expected != actual) | |
throw AssertionError("expected $expected, but actual $actual") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment