Rosen_Tenev

Untitled

Jan 31st, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _05.SpecialNumbers
  4. {
  5.     class SpecialNumbers
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int num = int.Parse(Console.ReadLine());
  10.  
  11.             for (int i = 1; i <= num; i++)
  12.             {
  13.                 int sum = 0;
  14.                 int tempDigit = i;
  15.                 while (tempDigit!=0)
  16.                 {
  17.                     int lastDigit = 0;
  18.                     lastDigit = tempDigit % 10;
  19.                     sum += lastDigit;
  20.                     tempDigit /= 10;
  21.                 }
  22.                 if (sum == 5 || sum == 7 || sum == 11 )
  23.                 {
  24.                     Console.WriteLine($"{i} -> True");
  25.                 }
  26.                 else
  27.                 {
  28.                     Console.WriteLine($"{i} -> False");
  29.                 }
  30.                
  31.             }
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment