Advertisement
desislava_topuzakova

06. Special Numbers

Apr 11th, 2021
829
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. n = int(input())
  2. # 1111 до 9999
  3. for number in range(1111, 10000):
  4.     # print only special
  5.     # вземем всяка една цифра
  6.     # 3456 -> 3    4    5   6
  7.     units = number % 10 # единици
  8.     tens = number // 10 % 10 # десетици
  9.     hundreds = number // 100 % 10 # стотици
  10.     thousands = number // 1000 # хилядни
  11.  
  12.     check1 = units != 0 and n % units == 0
  13.     check2 = tens != 0 and n % tens == 0
  14.     check3 = hundreds != 0 and n % hundreds == 0
  15.     check4 = n % thousands == 0
  16.  
  17.     if check1 and check2 and check3 and check4:
  18.         print(number, end=' ')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement