Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. namespace TopNumber
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. int range = int.Parse(Console.ReadLine());
  11.  
  12. for (int i = 17; i < range; i++)
  13. {
  14. string currentNumber = i.ToString();
  15. int[] currentNumberAsIntArray = new int[currentNumber.Length];
  16.  
  17. for (int j = 0; j < currentNumberAsIntArray.Length; j++)
  18. {
  19. currentNumberAsIntArray[j] = int.Parse(currentNumber[j].ToString());
  20.  
  21. }
  22. isDigitsSumDivisibleByEight(currentNumberAsIntArray);
  23. IsContaintsOddDigits(currentNumberAsIntArray);
  24.  
  25. }
  26.  
  27. }
  28.  
  29. static bool isDigitsSumDivisibleByEight(int[] arr)
  30. {
  31. bool isDigitsSumDivisbleBy8 = false;
  32. int sumOfDigits = 0;
  33. for (int i = 0; i < arr.Length; i++)
  34. {
  35. sumOfDigits += arr[i];
  36. }
  37.  
  38. if (sumOfDigits % 8 == 0)
  39. {
  40. isDigitsSumDivisbleBy8 = true;
  41. }
  42. return isDigitsSumDivisbleBy8;
  43.  
  44. }
  45. static bool IsContaintsOddDigits(int[] arr)
  46. {
  47. bool isContainsOddDigit = false;
  48. for (int k = 0; k < arr.Length; k++)
  49. {
  50. if (arr[k] % 2 != 0)
  51. {
  52. isContainsOddDigit = true;
  53. break;
  54. }
  55.  
  56. }
  57. return isContainsOddDigit;
  58.  
  59. }
  60.  
  61.  
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement