ã¯ãã㫠人ã«ãã£ã¦æ§ã ãªæ¸ãæ¹ãã§ãã¦ãã¾ãã®ãScalaã æ¬è¨äºã§ã¯ãéä¹ãæ±ããfacé¢æ°ãä¾ã«ãããã¤ãã®èå³æ·±ãããã°ã©ãã³ã°ã¹ã¿ã¤ã«ãç´¹ä»ãã¾ãã 以ä¸ã®ã³ã¼ãã¯ãREPLã§:pasteãããã¨ã§ãç°¡åã«åä½ã確èªã§ãã¾ãã æç¶ãããã°ã©ãã³ã° ç ´å£çæä½ããããããªãç·ãããããã°ã©ãã³ã°ã¹ã¿ã¤ã«ã def fac(n: Int) = { var result = 1 for (i <- 1 to n) { result *= i } result } å帰ã§æ¸ãããéãï¼ã¯ãï¼ã§ãã æ®éã®å帰 åå¦è æ³£ããã®å帰ã¹ã¿ã¤ã«ã def fac(n: Int): Int = if (n == 0) 1 else n * fac(n - 1) // å帰å¼ã³åºãã®å¤å´ã« * ã«ããæ¼ç®ããã ãã®ããã«æ¸ãã¨ã¹ã¿ãã¯ãã©ãã©ãæ¶è²»ããã®ã§ãå¾è¿°ããæ«å°¾å帰ã使ã£ãã»ããããã§
{{#tags}}- {{label}}
{{/tags}}