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 n = int.Parse(Console.ReadLine());
- TopNumber(n);
- }
- static void TopNumber(int n)
- {
- for (int i = 8; i <= n; i++)
- {
- int c = i;
- int odd = 0;
- int sum = 0;
- for (int j = 0; j < n.ToString().Length; j++)
- {
- if (c % 2 == 1)
- {
- odd++;
- }
- sum += c % 10;
- c /= 10;
- }
- if (sum % 8 == 0 && odd > 0)
- {
- Console.WriteLine(i);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement