Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp4
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- //всички числа от 1111 до 9999
- for (int thousands = 1; thousands <= 9; thousands++)
- {
- for (int hundreds = 1; hundreds <= 9; hundreds++)
- {
- for (int tens = 1; tens <= 9; tens++)
- {
- for (int units = 1; units <= 9; units++)
- {
- //n трябва да се дели на хилядните без остатък
- bool check1 = n % thousands == 0;
- //n трябва да се дели на стотиците без остатък
- bool check2 = n % hundreds == 0;
- //n трябва да се дели на десетиците без остатък
- bool check3 = n % tens == 0;
- //n трябва да се дели на единиците без остатък
- bool check4 = n % units == 0;
- if (check1 && check2 && check3 && check4)
- {
- Console.Write($"{thousands}{hundreds}{tens}{units} ");
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment