Personal tools

Talk:Euler problems/121 to 130

From HaskellWiki

< Talk:Euler problems(Difference between revisions)
Jump to: navigation, search
Line 18: Line 18:
 
Would responsible people be so kind as to check copyvio for this one?
 
Would responsible people be so kind as to check copyvio for this one?
 
As far as I'm concerned it is.
 
As far as I'm concerned it is.
  +
Just another thought: as you have solutions handy for most problems, couldn't those guarding these pages do the copyvio checking themselves?
 
[[User: hk|hk]]
 
[[User: hk|hk]]

Revision as of 14:44, 25 February 2008

On the Project Euler Forum I found the following solution for Problem 127, posted there by glguy.
main = print $ solve 99999

rad x = fromIntegral $ product $ map fst $ primePowerFactors $ fromIntegral x

solve :: Int -> Int solve n = sum [ c | (rc,c) <- invrads

                 , 2 * rc < c
                 , (ra, a) <- takeWhile (\(a,_)->(c > 2*rc*a)) invrads
                 , a < c `div` 2
                 , gcd ra rc == 1
                 , ra * rads ! (c - a) < c `div` rc]
   where
    rads :: UArray Int Int
    rads = listArray (1,n) $ map rad [1..n]
    invrads = sort $ map (\(a,b) -> (b, a)) $ assocs rads

Would responsible people be so kind as to check copyvio for this one? As far as I'm concerned it is. Just another thought: as you have solutions handy for most problems, couldn't those guarding these pages do the copyvio checking themselves? hk