Advertisement
Iskrenov84

10. Top Number

Feb 10th, 2022
906
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1. using System;
  2.  
  3. namespace P10._TopNumber
  4. {
  5.     internal class Program
  6.     {
  7.         static bool isDividible (int input)
  8.         {
  9.             int sum = 0;
  10.  
  11.             while (input > 0)
  12.             {
  13.                 sum += input % 10;
  14.                 input /= 10;
  15.             }
  16.             bool isDivisible = sum % 8 == 0;
  17.             return isDivisible;
  18.         }
  19.         static bool cntOdddigits (int input)
  20.         {
  21.             while (input > 0)
  22.             {
  23.                 int curetntDigit = input % 10;
  24.  
  25.                 if (curetntDigit % 2 == 1)
  26.                 {
  27.                     return true;    
  28.                 }
  29.                 input /= 10;
  30.             }
  31.             return false;
  32.         }
  33.         static void Main(string[] args)
  34.         {
  35.            
  36.             int input =int.Parse(Console.ReadLine());
  37.  
  38.             for (int i = 0; i < input; i++)
  39.             {
  40.                 if (isDividible(i) && cntOdddigits(i))
  41.                 {
  42.                     Console.WriteLine(i);
  43.                 }
  44.             }
  45.            
  46.         }
  47.     }
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement