Sichanov

special numbers

Aug 8th, 2021
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. n = int(input())
  2. # 1111 do 9999
  3. for number in range(1111, 10000):
  4.     # print only special
  5.     # vzemem vsqka edna cifra
  6.     # 3456 -> 3   4   5   6
  7.     units = number % 10  # edinicite
  8.     tens = number // 10 % 10  # deseticite
  9.     hundreds = number // 100 % 10 # stotici
  10.     thousands = number // 1000  # hilqdni
  11.     # 1. n % units == 0
  12.     # 2. n % tens == 0
  13.     # 3. n % hundreds == 0
  14.     # 4. n % thousands == 0
  15.     check1 = units != 0 and n % units == 0
  16.     check2 = tens != 0 and n % tens == 0
  17.     check3 = hundreds != 0 and n % hundreds == 0
  18.     check4 = n % thousands == 0
  19.  
  20.     if check1 and check2 and check3 and check4:
  21.         print(number, end=" ")
Advertisement
Add Comment
Please, Sign In to add comment