Advertisement
GabrielDas

Untitled

May 21st, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace P02SumOfDigits
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int num = Int32.Parse(Console.ReadLine());
  14.  
  15. int temp = num;
  16. int sum = 0;
  17.  
  18. while (num != 0)
  19. {
  20. int product = 1;
  21. int digit = num % 10;
  22. num = num / 10;
  23.  
  24. while (digit > 0)
  25. {
  26. product *= digit;
  27. digit--;
  28. }
  29. sum += product;
  30. }
  31.  
  32. if (sum == temp)
  33. {
  34. Console.WriteLine("yes");
  35. }
  36. else
  37. {
  38. Console.WriteLine("no");
  39. }
  40.  
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement