Problem 47

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

14 = 2 x 7

15 = 3 x 5

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

644 = 2² x 7 x 23

645 = 3 x 5 x 43

646 = 2 x 17 x 19.

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

project euler用に素数primes、素因数分解factorsのモジュールNumberを用意した。

import Number
import Data.List
consecutive m n =all((==m).toInteger.length).map (nub.factors)$[n..(n+m-1)]
p047 = find  (consecutive 4) [1..]
main = print p047
More Reading
Newer// Problem 57
Older// Problem 49