Advertisement
Lavig

СРС 1 семестр (5 завдання)

Dec 2nd, 2022
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. nums = []
  2. for i in range(10, 100):
  3.     first_list = [int(a) for a in str(i)]
  4.     second_list = [int(b) for b in str(i * 3)]
  5.     first_sum = sum(first_list)
  6.     second_sum = sum(second_list)
  7.     if first_sum == second_sum:
  8.         nums.append(i)
  9. length = len(nums)
  10. print("Існує", length, "двозначних чисел, сума цифр яких не змінюється при множенні числа на 3. Ці числа:" , str(nums)[1:-1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement