haskell 初学者劝学 haskell
查看原帖
haskell 初学者劝学 haskell
625398
_OTZ_楼主2024/10/5 23:23

haskell 自带的 Integer 是高精度的,很适合这个题目

因为没找到 scanl1' 所以写的代码有点奇怪,望大佬们指点


module Main where

import Data.List

main :: IO ()
main =
  read <$> getLine >>= \n ->
    print . sum $ scanl' (*) 1 [2 .. n]
2024/10/5 23:23
加载中...