Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace _01.SumFactorialEvenDigits
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int input = int.Parse(Console.ReadLine());
- int[] digits = IntToArray(input);
- int sum = 0;
- for (int i = 0; i < digits.Length; i++)
- {
- if (digits[i] % 2 == 0)
- {
- int factorial = 1;
- for (int j = 1; j <= digits[i]; j++)
- {
- factorial *= j;
- }
- sum += factorial;
- }
- else
- {
- continue;
- }
- }
- Console.WriteLine(sum);
- static int[] IntToArray(int input)
- {
- List<int> result = new List<int>();
- while (input > 0)
- {
- int digit = input % 10;
- result.Add(digit);
- input /= 10;
- }
- return result.ToArray();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement