SHARE
TWEET

06. Special Numbers

desislava_topuzakova May 31st, 2020 1,211 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. n = int(input())
  2. #1. генерираме всички числа от 1111 до 9999
  3. #2. за всяко едно число да го разбием на цифри
  4. #3. проверка дали е специално -> ако е специално го печатаме
  5.  
  6. for number in range(1111, 10000):
  7.     #разбивка
  8.     first_digit = number // 1000
  9.     second_digit = (number // 100) % 10
  10.     third_digit = (number // 10) % 10
  11.     forth_digit = number % 10
  12.  
  13.     #специално: 1. n % first == 0; 2. n % second == 0; 3. n % third == 0;
  14.     # 4.  n % forth == 0
  15.     check1 = first_digit != 0 and n % first_digit == 0
  16.     check2 = second_digit != 0 and n % second_digit == 0
  17.     check3 = third_digit != 0 and n % third_digit == 0
  18.     check4 = forth_digit != 0 and n % forth_digit == 0
  19.  
  20.     if check1 and check2 and check3 and check4:
  21.         print(str(number) + ' ', end='')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top