EularProject 47:具有相同个数因子的连续数字

EularProject 47:具有相同个数因子的连续数字

分类:EulerProjectPython

Distinct primes factors Problem 47 The first two consecutive numbers to have two distinct prime factors are:

14 = 2 × 7 15 = 3 × 5

The first three consecutive numbers to have three distinct prime factors are:

644 = 2 × 7 × 23 645 = 3 × 5 × 43 646 = 2 × 17 × 19.

Find the first four consecutive integers to have four distinct prime factors. What is the first of these numbers?

Answer: 134043

__author__ = ‘zhengyi’primeNum=4consecutiveNum=4from math import sqrt:k=int(sqrt(x))+1for i in range(2,k):if x%i==0::result=0for i in range(0,len(primeSet)):if x%primeSet[i]==0:result+=1while x%primeSet[i]==0:x//=primeSet[i]if x==1:return resultprimeSet=[]p=1consecutive=:p+=1if IsPrime(p):primeSet.append(p)consecutive=0else:if primeCount(p)==primeNum:consecutive+=1if consecutive==consecutiveNum:print(p-consecutiveNum+1)breakelse:consecutive=0

版权声明:本文为博主原创文章,,未经博主允许不得转载。

上一篇C++指针与数组下一篇决策树算法实现(train+test,matlab)

顶0踩0

找一个让心里安静和干净的地方,自己变得跟水晶一般透明,

EularProject 47:具有相同个数因子的连续数字

相关文章:

你感兴趣的文章:

标签云: