# projecteuler

committed 4695700

p47: add brute force solution

# problem_47.py

`+#!/usr/bin/env python`
`+# -*- coding: UTF-8 -*-`
`+`
`+"""`
`+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 primes`
`+factors. What is the first of these numbers?`
`+"""`
`+`
`+from util import primes`
`+`
`+`
`+def main():`
`+    num = 648`
`+    pfact = map(primes.getprimefactors, range(num, num + 4))`
`+    pfactcount = map(len, pfact)`
`+    while min(pfactcount) < 4:`
`+        if num % 10000 == 0:`
`+            print num, pfactcount, pfact`
`+        num += 1`
`+        pfact = map(primes.getprimefactors, range(num, num + 4))`
`+        pfactcount = map(len, pfact)`
`+    print '%d is the answer. The seq has factors %s' % (num, pfact)`
`+`
`+`
`+if __name__ == '__main__':`
`+    main()`
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.