Advertisement
Alekscho85

NumbersNotDivisibleBy3and7V2

Oct 26th, 2014
156
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. namespace _02.NumbersNotDivisibleBy3and7V2
  3. {
  4.     class NumbersNotDivisibleBy3and7V2
  5.     {
  6.         static void Main()
  7.         {
  8.             // We get one number
  9.             Console.WriteLine("Show me all numbers (not divisible by 3 and 7)");
  10.             Console.Write("Enter n= ");
  11.             int n = int.Parse(Console.ReadLine());
  12.  
  13.             for (int i = 1; i <= n; i++)
  14.             {
  15.                 // We skip numbers that can be divided by 3 and 7 here and print the rest
  16.                 if (!(i % 3 == 0) && !(i % 7 == 0))
  17.                 {
  18.                     Console.WriteLine(i);
  19.                 }
  20.             }
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement