]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/project-euler/070/070.factor
Harmonize spelling
[factor.git] / extra / project-euler / 070 / 070.factor
index 38aa022b3d125eb0e659cb751a9f497be9373d3b..07e45fff3d50c69fb93e49af624bca19a6112801 100644 (file)
@@ -1,8 +1,9 @@
 ! Copyright (c) 2010 Aaron Schaefer. All rights reserved.
 ! The contents of this file are licensed under the Simplified BSD License
 ! A copy of the license is available at http://factorcode.org/license.txt
-USING: arrays assocs combinators.short-circuit kernel math math.combinatorics
-    math.functions math.primes math.ranges project-euler.common sequences ;
+USING: arrays combinators.short-circuit kernel math math.combinatorics
+math.functions math.primes project-euler.common sequences
+sequences.extras ;
 FROM: project-euler.common => permutations? ;
 IN: project-euler.070
 
@@ -28,7 +29,7 @@ IN: project-euler.070
 ! --------
 
 ! For n/φ(n) to be minimised, φ(n) must be as close to n as possible; that is,
-! we want to maximise φ(n). The minimal solution for n/φ(n) would be if n was
+! we want to maximize φ(n). The minimal solution for n/φ(n) would be if n was
 ! prime giving n/(n-1) but since n-1 never is a permutation of n it cannot be
 ! prime.
 
@@ -47,14 +48,14 @@ IN: project-euler.070
     7 10^ sqrt >integer 1000 [ - ] [ + ] 2bi primes-between ; inline
 
 : n-and-phi ( seq -- seq' )
-    #! ( seq  = { p1, p2 } -- seq' = { n, φ(n) } )
+    ! ( seq  = { p1, p2 } -- seq' = { n, φ(n) } )
     [ product ] [ [ 1 - ] map product ] bi 2array ;
 
 : fit-requirements? ( seq -- ? )
     first2 { [ drop 7 10^ < ] [ permutations? ] } 2&& ;
 
 : minimum-ratio ( seq -- n )
-    [ [ first2 / ] map [ infimum ] keep index ] keep nth first ;
+    [ [ first2 / ] map arg-min ] keep nth first ;
 
 PRIVATE>