def solution(left: int, right: int)-> tuple:
# your code here
yueshu_dict = dict.fromkeys(range(1,10),0)
for i in range(left,right+1):
flag = 1
while flag <= i:
if i%flag == 0:
yueshu_dict[flag] += 1
flag += 1
return tuple(yueshu_dict.values())
assert solution(1, 4) == (4,2,1,1,0,0,0,0,0)
def solution(left: int, right: int)-> tuple:
# your code here
if left >= 1 and right <= 10**9:
approximation_list = []
for i in (rng := range(left, right + 1)):
n = 1
while n <= i:
if i % n == 0:
approximation_list.append(n)
n += 1
count_num = [approximation_list.count(i) for i in rng] + [0 for i in range(9-len(rng))]
return tuple(count_num)
else:
-1
assert solution(1, 4) == (4,2,1,1,0,0,0,0,0)
def solution(left: int, right: int)-> tuple:
if left<right:
l=left
r=right
else:
l=right
r=left
counts=[]
list=[]
for i in range(l,r+1):
for j in range(1,i+1):
if(i%j==0):
list.append(j)
list.sort()
for i in range(1,10):
num=list.count(i)
counts.append(num)
return tuple(counts)
assert solution(1, 4) == (4,2,1,1,0,0,0,0,0)
assert solution(4, 1) == (4,2,1,1,0,0,0,0,0)
def solution(l:int,r:int):
list_num = []
for i in list(range(l,r+1)):
for j in list(range(1,i+1)):
if i % j ==0:
list_num.append(j)
list_num2 = list(range(1,10))
for x in range(len(list_num2)):
if list_num2[x] in list_num:
list_num2[x] = list_num.count(list_num2[x])
else:
list_num2[x] = 0
return tuple(list_num2)
if __name__ == '__main__':
print(solution(1, 4))
def solution(left: int, right: int)-> tuple:
b=[y if j%y==0 else None for j in range(left,right+1) for y in range(left,right+1)]
return tuple(b.count(i) for i in range(1,10))
def solution(left: int, right: int)-> tuple:
result_map=dict().fromkeys(range(1,10),0)
for x in range(left, right + 1):
for i in range(1, int(math.sqrt(x)) + 1):
if x % i == 0:
if x // i != i:
result_map[int(str(i)[0])] += 1
result_map[int(str(x // i)[0])] += 1
else:
result_map[int(str(i)[0])] += 1
return tuple(result_map.value())
def solution(left: int, right: int)-> tuple:
# your code here
d = {'1': 0, '2': 0, '3': 0, '4': 0, '5': 0, '6': 0, '7': 0, '8': 0, '9': 0}
for i in range(left, right + 1):
for j in range(left, right + 1):
if i % j == 0:
d[str(j)[0]] += 1
return tuple(d.values())
assert solution(1, 4) == (4,2,1,1,0,0,0,0,0)
def solution(left: int, right: int)-> tuple:
l=[j for i in range(left,right+1) for j in range(1,i+1) if i%j==0]
d=dict((i,l.count(i)) for i in range(1,10))
return tuple(d.values())
assert solution(1, 4) == (4,2,1,1,0,0,0,0,0)
def solution(left: int, right: int)-> tuple:
res=[]
res_list=[]
for i in range(left,right+1):
for j in range(1,i+1):
if i%j==0:
res_list.append(j)
for i in range(1,10):
res.append(res_list.count(i))
return tuple(res)
assert solution(1, 4) == (4,2,1,1,0,0,0,0,0)