summaryrefslogtreecommitdiff
path: root/069.py
diff options
context:
space:
mode:
authorReiner Herrmann <reiner@reiner-h.de>2014-08-31 20:21:45 +0200
committerReiner Herrmann <reiner@reiner-h.de>2014-08-31 20:35:09 +0200
commit95341b61b030c9e1290f3b326cb7ec584f543aea (patch)
tree852386fa04d32eb859bca11c0eff7b5ef9e50f00 /069.py
parent571164d977f91925c4c76a292f74f5f93d09ae23 (diff)
moved files to higher directory after split to new repositoryHEADtrunk
Diffstat (limited to '069.py')
-rw-r--r--069.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/069.py b/069.py
new file mode 100644
index 0000000..99236c5
--- /dev/null
+++ b/069.py
@@ -0,0 +1,28 @@
+from common import sieve
+
+primes = sieve(1000000).primes()
+prime_list = [ p for p in primes if p < 1000 ]
+prime_list.sort()
+
+def phi(x):
+ if x in primes:
+ return x-1
+ product = x
+ for p in prime_list:
+ if p*p > x:
+ break
+ if x % p != 0:
+ continue
+ product *= (1 - 1/float(p))
+ return product
+
+maxn = 0
+maxres = 0
+
+for n in xrange(2, 1000001):
+ if n/phi(n) >= maxres:
+ maxres = n/phi(n)
+ maxn = n
+
+print maxn
+