Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace TopNumber
- {
- class Program
- {
- static void Main(string[] args)
- {
- int number = int.Parse(Console.ReadLine());
- for (int i = 1; i < number; i++)
- {
- if (SumOfDigits(i) % 8 == 0)
- {
- if (OddDigit(i))
- {
- Console.WriteLine(i);
- }
- }
- }
- }
- static int SumOfDigits(int i)
- {
- int sum = 0;
- while (i > 0)
- {
- sum += i % 10;
- i /= 10;
- }
- return sum;
- }
- static bool OddDigit(int i)
- {
- while (i > 0)
- {
- int digit = i % 10;
- if (digit % 2 != 0)
- {
- return true;
- }
- i /= 10;
- }
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement