Haskellã®åæ¨è«ã§ããã£ã話
ä¹
ãã¶ãã«Haskellã§éãã§ããããã£ãã®ã§ã¡ã¢ã
100ã®éä¹ 100!=1*2*...*100
ã®æ¡æ°ãæ±ããããã°ã©ã ãæ¸ããã
main = print $ kaijo 100 kaijo n = length $ show $ product [1..n] -- 158ã表示ãããã
ä¸è¨ã®ããã°ã©ã ã¯æ£ããå¤(158)ãè¿ãããä¸è¨ã®ããã«åãæ示ããã¨ã誤ã£ãå¤(0)ãè¿ãã
main = print $ kaijo 100 kaijo :: Int -> Int kaijo n = length $ show $ product [1..n] -- 0ã表示ãããããªãã§ãï¼ï¼
ã¡ãªã¿ã«100ã§ã¯ãªã10ã®éä¹ãªããã©ã¡ãã®ããã°ã©ã ãæ£ããçµæãè¿ãã
ãã®ä¸æ¡çã®åå ã¯ãIntãæ示ããã¨product
é¢æ°ã®è¨ç®ãIntã§å®è¡ããã¦ã
100ã®éä¹ã¨ãã大ããªå¤ãæ¡æº¢ããèµ·ããããã ã¨æãããã
Intãæ示ããªããã°ãèªåã§å¤åé·è¨ç®ãã¦ãããã
ã100ã158ã«ããé¢æ°ããªã®ã«ãInt -> Int
ã¨ããã¨ãã°ã£ã¡ãããããããããã