Project Euler

Problem 47: Distinct primes factors

Find the first four consecutive integers to have four distinct prime factors each. What is the first of these numbers? Run this solution at repl.io here.

      
        from prime_factors import prime_factors

        found = False
        n = 1

        while not found:
          if (len(prime_factors(n)) == 4 \
          and len(prime_factors(n+1)) == 4 \
          and len(prime_factors(n+2)) == 4 \
          and len(prime_factors(n+3)) == 4 ):
            answer = (n,n+1,n+2,n+3)
            found = True
          else:
            n += 1

        print(answer)
      
    

back to code menu