Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace _05._Good_numbers
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- int[] numbers = input
- .Split()
- .Select(int.Parse)
- .ToArray();
- int firstNumber = numbers[0];
- int lastNummber = numbers[1];
- int counter = 0;
- bool isValid = true;
- for (int i = firstNumber; i <= lastNummber; i++)
- {
- int currentNum = i;
- while (currentNum>0)
- {
- int digit = currentNum % 10;
- if (digit==0 || currentNum % digit == 0)
- {
- currentNum /= 10;
- continue;
- }
- else
- {
- isValid = false;
- break;
- }
- }
- if (isValid)
- {
- counter++;
- }
- else
- {
- continue;
- }
- }
- Console.WriteLine(counter);
- }
- }
- }
Add Comment
Please, Sign In to add comment