Advertisement
BorisSimeonov

Numbers in Interval Dividable by Given Number

Nov 17th, 2014
273
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. class NumbersDividableByNumber
  4. {
  5.     static void Main()
  6.     {
  7.         int startNum = int.Parse(Console.ReadLine());
  8.         int endNum = int.Parse(Console.ReadLine());
  9.         int counter = 0;
  10.         Console.Clear();
  11.         for (int cnt = startNum; cnt <= endNum; cnt++ )
  12.         {
  13.             if(cnt % 5 == 0)
  14.             {
  15.                 Console.Write(counter == 0 ? "{0}" : ",{0}", cnt);
  16.                 counter++;
  17.             }
  18.         }
  19.         if(counter == 0)
  20.         {
  21.             Console.Write("-");
  22.         }
  23.         Console.WriteLine("\r\nCount: {0} numbers.", counter);
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement