desislava_topuzakova

02. Equal Sums Even Odd Position

Apr 11th, 2021
503
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # 1. отпечатваме всички в дадения диапазон
  2. start_number = int(input())
  3. end_number = int(input())
  4.  
  5. for number in range(start_number, end_number + 1):
  6.     # сума от цифрите на четни позиции == сума от цифрите на нечетни позиции
  7.     # 376214
  8.     units = number % 10 # even
  9.     tens = number // 10 % 10 # odd
  10.     hundreds = number // 100 % 10 # even
  11.     thousands = number // 1000 % 10 #odd
  12.     tens_thousands = number // 10000 % 10 #even
  13.     hundred_thousands = number // 100000 # odd
  14.  
  15.     sum_even = units + hundreds + tens_thousands
  16.     sum_odd = tens + thousands + hundred_thousands
  17.     if sum_odd == sum_even:
  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.

×