Problem #20. Find the sum of the digits in the number 100!
번역: 100! 값의 모든 자릿수의 합을 구하시오.
여러가지 방법이 있을 수 있지만.
가장 직관적인 방법은 계산해서 더하면 된다.
open Microsoft.FSharp.Math
(BigInt.Factorial (BigInt 100)).ToString()
|> Seq.map (fun x -> (int x) - (int '0'))
|> Seq.sum
|> printfn "Problem #20 = %d"
'내 생산물' 카테고리의 다른 글
| [AI] 테트리스 AI v0.5 (4) | 2010/08/28 |
|---|---|
| F#, Project Euler - Problem #4 (2) (0) | 2009/05/22 |
| F#, Project Euler - Problem #12 (0) | 2009/05/12 |
| F#, Project Euler - Problem #20 (0) | 2009/05/12 |
| F#, Project Euler - Problem #5 (0) | 2009/05/11 |
| F#, Project Euler - Problem #4 (2) | 2009/05/11 |
| F#, Project Euler - Problem #1 (2) | 2009/05/10 |
