Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Enter the final number: ");
- int finalNum = int.Parse(Console.ReadLine());
- TopNumber(finalNum);
- }
- static void TopNumber(int finalNum)
- {
- for(int i = 1; i <= finalNum; i++)
- {
- bool divisable = false;
- bool oddNum = false;
- int helpNum = 0;
- int helpNum2 = i;
- int sum = 0;
- while (helpNum2 > 0)
- {
- helpNum = helpNum2 % 10;
- if(helpNum % 2 != 0)
- {
- oddNum = true;
- }
- sum += helpNum;
- helpNum2 /= 10;
- }
- if(sum % 8 == 0)
- {
- divisable = true;
- }
- if(divisable == true && oddNum == true)
- {
- Console.WriteLine(i);
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment