diff --git a/C#/20.Factorial Digit Sum/frangiz.cs b/C#/20.Factorial Digit Sum/frangiz.cs new file mode 100644 index 0000000..b99ce64 --- /dev/null +++ b/C#/20.Factorial Digit Sum/frangiz.cs @@ -0,0 +1,32 @@ +using System; +using System.Numerics; +using System.Linq; + +namespace FactorialDigitSum +{ + public class MainClass + { + public static void Main() + { + BigInteger number = factorial(new BigInteger(100)); + + int ans = 0; + foreach (char c in number.ToString()) + { + ans += c - '0'; + } + Console.WriteLine(ans); + } + + private static BigInteger factorial(BigInteger n) + { + BigInteger res = new BigInteger(1); + while (n > 1) + { + res *= n; + n -= 1; + } + return res; + } + } +} \ No newline at end of file diff --git a/README.md b/README.md index b794d72..bb95dcf 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ Happy Contributing! 😃 | 17 | [Number letter counts](https://projecteuler.net/problem=17) | | | | :white_check_mark: | | | | | | | | | | 18 | [Maximum path sum I](https://projecteuler.net/problem=18) | | | | :white_check_mark: | | | | | | | | | | 19 | [Counting Sundays](https://projecteuler.net/problem=19) | | | | | | | | | | | | | -| 20 | [Factorial digit sum](https://projecteuler.net/problem=20) | | :white_check_mark: | | :white_check_mark: | :white_check_mark: | | | | | | | | +| 20 | [Factorial digit sum](https://projecteuler.net/problem=20) | | :white_check_mark: | | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | | | | | | 21 | [Amicable numbers](https://projecteuler.net/problem=21) | | | | | | | | | | | | | | 22 | [Names scores](https://projecteuler.net/problem=22) | | | | :white_check_mark: | | | | | | | | | | 23 | [Non-abundant sums](https://projecteuler.net/problem=23) | | | | | | | | | | | | |