Advertisement
kuruku

NumbersNotDivisibleByThreeAndSeven

May 3rd, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.62 KB | None | 0 0
  1. using System;
  2.  
  3. //Write a program that enters from the console a positive integer n and prints all the numbers from 1 to n
  4. //not divisible by 3 and 7, on a single line, separated by a space
  5.  
  6.     class NumbersNotDivisibleByThreeAndSeven
  7.     {
  8.         static void Main()
  9.         {
  10.             Console.Write("N = ");
  11.             int n = int.Parse(Console.ReadLine());
  12.             for (int i = 1; i <= n; i++)
  13.             {
  14.                 if (!(i % 7 == 0 || i % 3 == 0))
  15.                 {
  16.                     Console.Write("{0} ", i);
  17.                 }
  18.             }
  19.             Console.WriteLine();
  20.         }
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement