Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- number = int(input())
- for i in range(1, number + 1):
- current = str(i)
- sum = 0
- for j in range(len(current)):
- sum += int(current[j])
- is_special = False
- if sum == 5 or sum == 7 or sum == 11:
- is_special = True
- print(f'{i} -> {is_special}')
- Или:
- for i in range(1, int(input()) + 1):
- current = str(i)
- total = 0
- for j in range(len(current)):
- total += int(current[j])
- print(f'{i} -> {total == 5 or total == 7 or total == 11}')
- Или:
- for i in range(1, int(input()) + 1):
- current = i
- total = 0
- while current > 0:
- total += current % 10
- current /= 10
- print(f'{i} -> {total == 5 or total == 7 or total == 11}')
- Тарикатско решение:
- for i in range(1, int(input()) + 1):
- total = sum([int(i) for i in list(str(i))])
- print(f'{i} -> {total == 5 or total == 7 or total == 11}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement