Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace TopNumber
- {
- class Program
- {
- static void Main(string[] args)
- {
- int range = int.Parse(Console.ReadLine());
- for (int i = 17; i < range; i++)
- {
- string currentNumber = i.ToString();
- int[] currentNumberAsIntArray = new int[currentNumber.Length];
- for (int j = 0; j < currentNumberAsIntArray.Length; j++)
- {
- currentNumberAsIntArray[j] = int.Parse(currentNumber[j].ToString());
- }
- isDigitsSumDivisibleByEight(currentNumberAsIntArray);
- IsContaintsOddDigits(currentNumberAsIntArray);
- }
- }
- static bool isDigitsSumDivisibleByEight(int[] arr)
- {
- bool isDigitsSumDivisbleBy8 = false;
- int sumOfDigits = 0;
- for (int i = 0; i < arr.Length; i++)
- {
- sumOfDigits += arr[i];
- }
- if (sumOfDigits % 8 == 0)
- {
- isDigitsSumDivisbleBy8 = true;
- }
- return isDigitsSumDivisbleBy8;
- }
- static bool IsContaintsOddDigits(int[] arr)
- {
- bool isContainsOddDigit = false;
- for (int k = 0; k < arr.Length; k++)
- {
- if (arr[k] % 2 != 0)
- {
- isContainsOddDigit = true;
- break;
- }
- }
- return isContainsOddDigit;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement