VelizarAvramov

09. Refactor Special Numbers

Nov 14th, 2019
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _09._Refactor_Special_Numbers
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.  
  11.  
  12.             for (int i = 1; i <= n; i++)
  13.             {
  14.                 int sum = 0;
  15.                 int current = i;
  16.                 while (current != 0)
  17.                 {
  18.                     sum += current % 10;
  19.                     current /= 10;
  20.                 }
  21.                 bool isSpecial = false;
  22.                 isSpecial = (sum == 5) || (sum == 7) || (sum == 11);
  23.                 Console.WriteLine($"{i} -> {isSpecial}");
  24.             }
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment