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