codewars--Primes with Even Digits

在 Codewars 上解决 'Primes with Even Digits' 问题,找到小于给定整数 n 的最接近的质数,该质数具有尽可能多的偶数位。例如,对于 n=1000,最高质数是887,包含两个偶数位(8)。文章介绍了多种解决方案,包括使用字典存储质数及其偶数位数量,并进行排序查找。
摘要由CSDN通过智能技术生成

Codewars–Stay away for many days

Problem Description:

点击此处获取题目
Find the closest prime number under a certain integer n that has the maximum possible amount of even digits.

For n = 1000, the highest prime under 1000 is 887, having two even digits (8 twice)

Naming f(), the function that gives that prime, the above case and others will be like the following below.

f(1000) —> 887 (even digits: 8, 8)

f(1210) —> 1201 (even digits: 2, 0)

f(10000) —> 8887

f(500) —> 487

f(487) —> 467

Features of the random tests:

Number of tests = 28
1000 <= n <= 5000000
在这里插入图片描述


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值