Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace C_
- {
- using System;
- using System.Globalization;
- public class Program
- {
- public static void Main()
- {
- int number = int.Parse(Console.ReadLine());
- int sum = 0;
- int originalNum = number;
- // WE ASSIGN THE ORIGINAL NUMBER'S VALUE TO A VARIABLE
- // BECASUE WE ARE GOING TO NEED IT LATER BUT THE ORIGINAL NUMBER'S
- //VALUE IS GOING TO BECHANGED
- while(number > 0) // IF THE NUMBER IS LESS THAN ZERO LOOP BREAKS;
- {
- int factorial = 1;
- int lastDigit = number % 10; // We GET THE LAST DIGIT OF THE NUMEBR
- for (int i = 1; i <= lastDigit; i++) // WE GET THE FACTORIAL HERE
- {
- factorial *= i;
- }
- sum += factorial; // WE SUM THE FACTORIALS BECAUSE WE
- // WILL NEED TO CHECK IF THE SUM IS EQUAL
- // TO THE ORIGINAL NUMBER SO WE DETERMINE
- // WHETHER IT IS STROGN OR NOT
- number /= 10; // THIS DIVISION IS DONE BECAUSE WE
- // NEED TO REMOVE THE LAST DIGIT AFTER EACH
- // ITERATION
- }
- if(originalNum == sum)
- {
- Console.WriteLine("yes");
- }
- else
- {
- Console.WriteLine("no");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement