Advertisement
dimipan80

6.2Loops_PrintNumbersThatAreNotDivisibleBy3And7

Mar 23rd, 2014
768
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1. using System;
  2.  
  3. class NotDivisible3And7All1ToNNumbers
  4. {
  5.     static void Main ()
  6.     {
  7.         Console.Write("Please, enter a whole positive number for N = ");
  8.         string numberStr = Console.ReadLine();
  9.         int numberN = int.Parse(numberStr);
  10.         if (numberN < 1)
  11.         {
  12.             Console.WriteLine("Error - Invalid Number !!!");
  13.         }
  14.         else
  15.         {
  16.             Console.Write("The all numbers from 1 to that number N, wich not divisible"
  17.         + " by 3 and 7 at the same time, are: ");
  18.             for (int i = 1; i <= numberN; i++)
  19.             {
  20.                 if ((i % (3 * 7)) != 0)
  21.                 {
  22.                     Console.Write("{0} ", i);
  23.                 }                
  24.             }
  25.         }
  26.         Console.ReadLine();
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement