Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Security.Cryptography;
- 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++)
- {
- string checkNumber=i.ToString();
- for (int j = 0; j < checkNumber.Length; j++) //deli chisloto na vsqko ot chislata
- {
- char digit = checkNumber[j];
- if (digit-'0' == 0)
- {
- if (j==checkNumber.Length-1)
- {
- counter++; continue;
- }
- else
- {
- continue;
- }
- }
- isValid = i % (digit - '0') == 0;
- if (!isValid)
- {
- break;
- }
- if (isValid&&j==checkNumber.Length-1)
- {
- counter++;
- }
- }
- }
- Console.WriteLine(counter);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment