Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. using System;
  2.  
  3. namespace TopNumber
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int number = int.Parse(Console.ReadLine());
  10.  
  11. for (int i = 1; i < number; i++)
  12. {
  13. if (SumOfDigits(i) % 8 == 0)
  14. {
  15. if (OddDigit(i))
  16. {
  17. Console.WriteLine(i);
  18. }
  19. }
  20. }
  21. }
  22.  
  23. static int SumOfDigits(int i)
  24. {
  25. int sum = 0;
  26. while (i > 0)
  27. {
  28. sum += i % 10;
  29. i /= 10;
  30. }
  31. return sum;
  32. }
  33.  
  34. static bool OddDigit(int i)
  35. {
  36. while (i > 0)
  37. {
  38. int digit = i % 10;
  39. if (digit % 2 != 0)
  40. {
  41. return true;
  42. }
  43. i /= 10;
  44. }
  45. return false;
  46.  
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement