首页 > 代码库 > Problem 35:Circular primes
Problem 35:Circular primes
Circular primes
p = (lambda n,s=set():{‘2‘}|{str(i) for i in range(3,n,2) if ([j for j in range(i*3,n,i*2) if s.add(j)] or i not in s)})(int(1e6))print(list(filter(lambda n:{‘‘.join([n[i-j] for i in range(len(n))]) for j in range(len(n))} < p, p)))
p = (lambda n,s=set():{‘2‘}|{str(i) for i in range(3,n,2) if ([j for j in range(i*3,n,i*2) if s.add(j)] or i not in s)})(int(1e6))print(list(filter(lambda n:{‘‘.join([n[i-j] for i in range(len(n))]) for j in range(len(n))} < p, p)))
$S^2+\frac{1}{2}$
The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime.
There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97.
How many circular primes are there below one million?
1 p = (lambda n,s=set():{‘2‘}|{str(i) for i in range(3,n,2) if ([j for j in range(i*3,n,i*2) if s.add(j)] or i not in s)})(int(1e6))2 print(list(filter(lambda n:{‘‘.join([n[i-j] for i in range(len(n))]) for j in range(len(n))} < p, p)))
Problem 35:Circular primes
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。