! Copyright (c) 2008 Eric Mertens.
! See http://factorcode.org/license.txt for BSD license.
-USING: kernel sequences math math.functions math.ranges locals project-euler.common ;
+USING: kernel sequences math math.functions ranges project-euler.common ;
IN: project-euler.190
! http://projecteuler.net/index.php?section=problems&id=190
! Let Sm = (x1, x2, ... , xm) be the m-tuple of positive real numbers
! with x1 + x2 + ... + xm = m for which Pm = x1 * x22 * ... * xmm is
-! maximised.
+! maximized.
! For example, it can be verified that [P10] = 4112 ([ ] is the integer
! part function).
PRIVATE>
:: P_m ( m -- P_m )
- m [1,b] [| i | 2 i * m 1+ / i ^ ] PI ;
+ m [1..b] [| i | 2 i * m 1 + / i ^ ] PI ;
: euler190 ( -- answer )
- 2 15 [a,b] [ P_m truncate ] sigma ;
+ 2 15 [a..b] [ P_m truncate ] map-sum ;
! [ euler150 ] 100 ave-time
! 5 ms ave run time - 1.01 SD (100 trials)