Venciity

[ Telerik C#] LOOPS - EX 2

Feb 9th, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. //Write a program that prints all the numbers from 1 to N, that are not divisible by 3 and 7 at the same time.
  2.  
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace ex1
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             Console.Write("number = ");
  16.             int number = Int32.Parse(Console.ReadLine());
  17.             for (int i = 1; i <= number; i++)
  18.             {
  19.                 if (i % 3 == 0 && i % 7 == 0)
  20.                 {
  21.                     continue;
  22.                 }
  23.                 else
  24.                 {
  25.                     Console.WriteLine("{0}", i);
  26.                 }
  27.             }
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment