Advertisement
Guest User

_11.Numbers_in_Interval_Dividable_by_Given_Number

a guest
Nov 19th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. static void Main()
  2.         {
  3.             Console.Write("Enter the start of the interval: ");
  4.             int a = int.Parse(Console.ReadLine());
  5.             Console.Write("Enter the end of the interval: ");
  6.             int b = int.Parse(Console.ReadLine());
  7.             Console.WriteLine("Enter the number which you would like the interval to be divided with: ");
  8.             int n = int.Parse(Console.ReadLine());
  9.             if (a < 0 || b < 0)
  10.             {
  11.                 Console.WriteLine("Enter positive numbers!");
  12.             }
  13.             else if (n == 0)
  14.             {
  15.                 Console.WriteLine("p = 0");
  16.                 Console.WriteLine("-");
  17.             }
  18.             else
  19.             {
  20.                 Console.WriteLine();
  21.                 for (int i = a; i <= b; i++)
  22.                 {
  23.                     if (i % n == 0)
  24.                     {
  25.                         Console.Write(i + " ");
  26.                     }
  27.  
  28.                 }
  29.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement