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
| // フィボナッチ数列 単純版 | |
| def fib(n:Int):Int = { | |
| n match { | |
| case x if (x <= 1) => x | |
| case _ => fib(n - 1) + fib(n - 2) | |
| } | |
| } |
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
| // 階乗計算 | |
| def fact(n: Int): Int = { | |
| n match { | |
| case 0 => 1 | |
| case _ => n * (n - 1) | |
| } | |
| } |
NewerOlder