Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // resharper disable all
- string input = Console.ReadLine()!;
- int factorialSum = 0;
- for (int i = 0; i < input.Length; i++)
- {
- char currentChar = input[i];
- int parsedChar = int.Parse(currentChar.ToString());
- int factForThisChar = 1;
- for (int j = 1; j <= parsedChar; j++)
- {
- factForThisChar = factForThisChar * j;
- }
- factorialSum += factForThisChar;
- }
- int inputParsed = int.Parse(input);
- int factForInput = 1;
- for (int i = 1; i <= inputParsed; i++)
- {
- factForInput = factForInput * i;
- }
- if (factForInput != factorialSum)
- {
- Console.WriteLine("not equal :(");
- }
- else
- {
- Console.WriteLine("equal!!! :D");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement