题解 | #挑7#
挑7
https://www.nowcoder.com/practice/ba241b85371c409ea01ac0aa1a8d957b
#1 Multiples of 7: % == 0 #2 Include 7: str(n) and search for 7 # Overlap of #1 and #2 can use or n = int(input()) c = 0 for i in range(1, n+1): if '7' in str(i) or i % 7 == 0: c += 1 print(c)
用or来合并同时能被7整除以及含有7的情况