给定一个质数列表primesL
和一个整数 limit
,尝试找到在limit
数字范围内所有满足质数列表primesL
组合的合数的个数,以及最大的合数
例子
primesL = [2, 5, 7]
limit = 500
List of Numbers Under 500 Prime Factorization
___________________________________________________________
70 [2, 5, 7]
140 [2, 2, 5, 7]
280 [2, 2, 2, 5, 7]
350 [2, 5, 5, 7]
490 [2, 5, 7, 7]
下面有5
个合数是满足的,最大的一个是490
。
您必须创建函数count_find_num()
,它接受两个参数:primesL
和limit
,并返回满足要求的数字数量,以及limit
下的最大数字。
场景1:
primesL = [2, 5, 7]
limit = 500
count_find_num(primesL, val) == [5, 490]
场景2:
primesL = [2, 3, 47]
limit = 200
count_find_num(primesL, limit) == []
场景3:
primesL = [2, 3, 47]
limit = 282
count_find_num(primesL, limit) == [1, 282]
题目难度:中等
题目来源: https://www.codewars.com/kata/58f9f9f58b33d1b9cf00019d
def count_find_num(primesL: list, limit: int) -> list:
# your code here
return []
assert count_find_num( [2, 5, 7], 500) == [5, 490]
assert count_find_num( [2, 3, 47], 200) == []
assert count_find_num( [2, 3, 47], 282) == [1, 282]
assert count_find_num( [2, 3, 5], 1000) == [19, 960]