GCF/LCM in Haskell
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm extremely new to Haskell. Is there a simple way to find the GCF or LCM (Least Common Multiple) in Haskell? 回答1: I'm not sure what the LCF is but the GCF is a Haskell favorite. Using the Euclidean Algroithm you can really get a sense of how Haskell works. http://en.wikipedia.org/wiki/Euclidean_algorithm There is a great explanation of how the algorithm is set up here http://en.literateprograms.org/Euclidean_algorithm_(Haskell) . This type of recursion is common in Haskell and it shows how expressive the language can be. gcd a 0 = a gcd a