Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Console.Write("Enter the start of the interval: ");
- int a = int.Parse(Console.ReadLine());
- Console.Write("Enter the end of the interval: ");
- int b = int.Parse(Console.ReadLine());
- Console.WriteLine("Enter the number which you would like the interval to be divided with: ");
- int n = int.Parse(Console.ReadLine());
- int count = 0;
- if (a < 0 || b < 0)
- {
- Console.WriteLine("Enter positive numbers!");
- }
- else if (n == 0)
- {
- Console.WriteLine("p = 0");
- Console.WriteLine("-");
- }
- else
- {
- Console.WriteLine();
- for (int i = a; i <= b; i++)
- {
- if (i % n == 0)
- {
- Console.Write(i + " ");
- count++;
- }
- }
- Console.WriteLine("\nThe number of the numbers, which were divided (p) is: {0}",count);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement