desislava_topuzakova

06. Special Numbers

Apr 11th, 2021
634
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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=' ')
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×